Mercurial > hg > octave-kai > gnulib-hg
annotate lib/acl-internal.h @ 10114:51164d97e89b
Make copy_acl work on MacOS X 10.5.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 23 May 2008 01:13:51 +0200 |
parents | 29794e333189 |
children | 4e8f2032eb4d |
rev | line source |
---|---|
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* Internal implementation of access control lists. |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
2 |
10109
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
3 Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc. |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8583
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8583
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8583
diff
changeset
|
8 (at your option) any later version. |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8583
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
17 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 Written by Paul Eggert and Andreas Gruenbacher. */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 #include "acl.h" |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
21 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 #include <stdbool.h> |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
23 #include <stdlib.h> |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
24 |
10109
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
25 /* All systems define the ACL related API in <sys/acl.h>. */ |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
26 #if HAVE_SYS_ACL_H |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
27 # include <sys/acl.h> |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
28 #endif |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
29 #if defined HAVE_ACL && ! defined GETACLCNT && defined ACL_CNT |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
30 # define GETACLCNT ACL_CNT |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
31 #endif |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
32 |
29794e333189
Move some declarations from acl.h to acl-internal.h.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
33 /* On Linux, additional ACL related API is available in <acl/libacl.h>. */ |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
34 #ifdef HAVE_ACL_LIBACL_H |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
35 # include <acl/libacl.h> |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
36 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
37 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
38 #include "error.h" |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
39 #include "quote.h" |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
40 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
41 #include <errno.h> |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
42 #ifndef ENOSYS |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
43 # define ENOSYS (-1) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
44 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
45 #ifndef ENOTSUP |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 # define ENOTSUP (-1) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
48 |
8479
19b8b337ecaa
Suggestions by Bruno Haible:
Paul Eggert <eggert@cs.ucla.edu>
parents:
8476
diff
changeset
|
49 #include "gettext.h" |
19b8b337ecaa
Suggestions by Bruno Haible:
Paul Eggert <eggert@cs.ucla.edu>
parents:
8476
diff
changeset
|
50 #define _(msgid) gettext (msgid) |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
51 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
52 #ifndef HAVE_FCHMOD |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
53 # define HAVE_FCHMOD false |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
54 # define fchmod(fd, mode) (-1) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
55 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
56 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
57 #ifndef MIN_ACL_ENTRIES |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
58 # define MIN_ACL_ENTRIES 4 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
59 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
60 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
61 /* POSIX 1003.1e (draft 17) */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
62 #ifndef HAVE_ACL_GET_FD |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
63 # define HAVE_ACL_GET_FD false |
8583
651c62bbc302
* lib/acl-internal.h (acl_get_fd, acl_set_fd): undef before defining,
Paul Eggert <eggert@cs.ucla.edu>
parents:
8479
diff
changeset
|
64 # undef acl_get_fd |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
65 # define acl_get_fd(fd) (NULL) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
66 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
67 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
68 /* POSIX 1003.1e (draft 17) */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
69 #ifndef HAVE_ACL_SET_FD |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
70 # define HAVE_ACL_SET_FD false |
8583
651c62bbc302
* lib/acl-internal.h (acl_get_fd, acl_set_fd): undef before defining,
Paul Eggert <eggert@cs.ucla.edu>
parents:
8479
diff
changeset
|
71 # undef acl_set_fd |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
72 # define acl_set_fd(fd, acl) (-1) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
73 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
74 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
75 /* Linux-specific */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
76 #ifndef HAVE_ACL_EXTENDED_FILE |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
77 # define HAVE_ACL_EXTENDED_FILE false |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
78 # define acl_extended_file(name) (-1) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
79 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
80 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
81 /* Linux-specific */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
82 #ifndef HAVE_ACL_FROM_MODE |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
83 # define HAVE_ACL_FROM_MODE false |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
84 # define acl_from_mode(mode) (NULL) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
85 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
86 |
10114
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
87 /* Set to 1 if a file's mode is implicit by the ACL. |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
88 Set to 0 if a file's mode is stored independently from the ACL. */ |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
89 #if HAVE_ACL_COPY_EXT_NATIVE && HAVE_ACL_CREATE_ENTRY_NP /* MacOS X */ |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
90 # define MODE_INSIDE_ACL 0 |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
91 #else |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
92 # define MODE_INSIDE_ACL 1 |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
93 #endif |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
94 |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
95 #if defined __APPLE__ && defined __MACH__ /* MacOS X */ |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
96 # define ACL_NOT_WELL_SUPPORTED(Err) \ |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
97 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY || (Err) == ENOENT) |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
98 #else |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
99 # define ACL_NOT_WELL_SUPPORTED(Err) \ |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
100 ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY) |
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
10109
diff
changeset
|
101 #endif |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
102 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
103 /* Define a replacement for acl_entries if needed. */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
104 #if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE && !HAVE_ACL_ENTRIES |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
105 # define acl_entries rpl_acl_entries |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
106 int acl_entries (acl_t); |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
107 #endif |