annotate lib/set-acl.c @ 17814:f50001a9c124

autoupdate
author Karl Berry <karl@freefriends.org>
date Wed, 03 Dec 2014 07:04:40 -0800
parents 344018b6e5d7
children ab58d4870664
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17381
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* set-acl.c - set access control list equivalent to a mode
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17587
344018b6e5d7 maint: update copyright
Eric Blake <eblake@redhat.com>
parents: 17391
diff changeset
3 Copyright (C) 2002-2003, 2005-2014 Free Software Foundation, Inc.
17381
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8 (at your option) any later version.
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 GNU General Public License for more details.
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 #include <config.h>
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 #include "acl.h"
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23
17385
239b8a8792bf acl: include errno.h to get errno
Paul Eggert <eggert@cs.ucla.edu>
parents: 17381
diff changeset
24 #include <errno.h>
239b8a8792bf acl: include errno.h to get errno
Paul Eggert <eggert@cs.ucla.edu>
parents: 17381
diff changeset
25
17391
e33e6edcd3a1 acl: include quote.h
Mike Frysinger <vapier@gentoo.org>
parents: 17385
diff changeset
26 #include "quote.h"
17381
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27 #include "error.h"
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 #include "gettext.h"
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 #define _(msgid) gettext (msgid)
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 /* Set the access control lists of a file. If DESC is a valid file
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 descriptor, use file descriptor operations where available, else use
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34 filename based operations on NAME. If access control lists are not
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 available, fchmod the target file to MODE. Also sets the
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36 non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX)
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
37 to those from MODE if any are set.
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
38 Return 0 if successful. On failure, output a diagnostic, set errno and
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
39 return -1. */
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
40
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 int
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 set_acl (char const *name, int desc, mode_t mode)
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 {
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
44 int ret = qset_acl (name, desc, mode);
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 if (ret != 0)
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
46 error (0, errno, _("setting permissions for %s"), quote (name));
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47 return ret;
915d2ad64b47 qacl: new module, broken out from the acl module
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48 }