Mercurial > hg > octave-shane > gnulib-hg
annotate lib/file-has-acl.c @ 17282:a4996fb12971
locale: port to Solaris 2.6 and 7 + GNU gettext
* lib/locale.in.h: Just include_next <locale.h> when
being invoked recursively. This prevents problems on Solaris 2.6 and 7
when combining the localename module with GNU gettext 0.18.2.
Problem reported by Tom G. Christensen in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00084.html>.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 10 Jan 2013 13:24:13 -0800 |
parents | e542fd46ad6f |
children | 915d2ad64b47 |
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 /* Test whether a file has a nontrivial access control list. |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16935
diff
changeset
|
3 Copyright (C) 2002-2003, 2005-2013 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:
8476
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:
8476
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:
8476
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:
8476
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 |
10184 | 18 Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 |
16343
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
20 /* Without this pragma, gcc 4.7.0 20120126 may suggest that the |
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
21 file_has_acl function might be candidate for attribute 'const' */ |
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
22 #if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ |
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
23 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const" |
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
24 #endif |
3bec4206b1cc
file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
25 |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
26 #include <config.h> |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
27 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
28 #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
|
29 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
30 #include "acl-internal.h" |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
31 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
32 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
33 #if USE_ACL && HAVE_ACL_GET_FILE |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
34 |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16383
diff
changeset
|
35 # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ |
10177
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
36 |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
37 /* ACL is an ACL, from a file, stored as type ACL_TYPE_EXTENDED. |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
38 Return 1 if the given ACL is non-trivial. |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
39 Return 0 if it is trivial. */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
40 int |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
41 acl_extended_nontrivial (acl_t acl) |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
42 { |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
43 /* acl is non-trivial if it is non-empty. */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
44 return (acl_entries (acl) > 0); |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
45 } |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
46 |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
47 # else /* Linux, FreeBSD, IRIX, Tru64 */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
48 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
49 /* ACL is an ACL, from a file, stored as type ACL_TYPE_ACCESS. |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
50 Return 1 if the given ACL is non-trivial. |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
51 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
52 Return -1 and set errno upon failure to determine it. */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
53 int |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
54 acl_access_nontrivial (acl_t acl) |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
55 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
56 /* acl is non-trivial if it has some entries other than for "user::", |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
57 "group::", and "other::". Normally these three should be present |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
58 at least, allowing us to write |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
59 return (3 < acl_entries (acl)); |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
60 but the following code is more robust. */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
61 # if HAVE_ACL_FIRST_ENTRY /* Linux, FreeBSD */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
62 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
63 acl_entry_t ace; |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
64 int got_one; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
65 |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
66 for (got_one = acl_get_entry (acl, ACL_FIRST_ENTRY, &ace); |
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
67 got_one > 0; |
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
68 got_one = acl_get_entry (acl, ACL_NEXT_ENTRY, &ace)) |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
69 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
70 acl_tag_t tag; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
71 if (acl_get_tag_type (ace, &tag) < 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
72 return -1; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
73 if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
74 return 1; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
75 } |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
76 return got_one; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
77 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
78 # else /* IRIX, Tru64 */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
79 # if HAVE_ACL_TO_SHORT_TEXT /* IRIX */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
80 /* Don't use acl_get_entry: it is undocumented. */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
81 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
82 int count = acl->acl_cnt; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
83 int i; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
84 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
85 for (i = 0; i < count; i++) |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
86 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
87 acl_entry_t ace = &acl->acl_entry[i]; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
88 acl_tag_t tag = ace->ae_tag; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
89 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
90 if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
91 || tag == ACL_OTHER_OBJ)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
92 return 1; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
93 } |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
94 return 0; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
95 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
96 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
97 # if HAVE_ACL_FREE_TEXT /* Tru64 */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
98 /* Don't use acl_get_entry: it takes only one argument and does not work. */ |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
99 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
100 int count = acl->acl_num; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
101 acl_entry_t ace; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
102 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
103 for (ace = acl->acl_first; count > 0; ace = ace->next, count--) |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
104 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
105 acl_tag_t tag; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
106 acl_perm_t perm; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
107 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
108 tag = ace->entry->acl_type; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
109 if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
110 return 1; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
111 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
112 perm = ace->entry->acl_perm; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
113 /* On Tru64, perm can also contain non-standard bits such as |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
114 PERM_INSERT, PERM_DELETE, PERM_MODIFY, PERM_LOOKUP, ... */ |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
115 if ((perm & ~(ACL_READ | ACL_WRITE | ACL_EXECUTE)) != 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
116 return 1; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
117 } |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
118 return 0; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
119 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
120 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
121 # endif |
10177
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
122 } |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
123 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
124 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
125 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
126 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
127 #elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
128 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
129 /* Test an ACL retrieved with GETACL. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
130 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
131 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
132 int |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
133 acl_nontrivial (int count, aclent_t *entries) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
134 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
135 int i; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
136 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
137 for (i = 0; i < count; i++) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
138 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
139 aclent_t *ace = &entries[i]; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
140 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
141 /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
142 If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
143 We don't need to check ace->a_id in these cases. */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
144 if (!(ace->a_type == USER_OBJ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
145 || ace->a_type == GROUP_OBJ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
146 || ace->a_type == OTHER_OBJ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
147 /* Note: Cygwin does not return a CLASS_OBJ ("mask:") entry |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
148 sometimes. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
149 || ace->a_type == CLASS_OBJ)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
150 return 1; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
151 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
152 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
153 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
154 |
15572
dd7c06a51643
acl: Clean up Solaris code.
Bruno Haible <bruno@clisp.org>
parents:
15571
diff
changeset
|
155 # ifdef ACE_GETACL |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
156 |
16380
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
157 /* A shortcut for a bitmask. */ |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
158 # define NEW_ACE_WRITEA_DATA (NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
159 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
160 /* Test an ACL retrieved with ACE_GETACL. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
161 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
162 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
163 int |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
164 acl_ace_nontrivial (int count, ace_t *entries) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
165 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
166 int i; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
167 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
168 /* The flags in the ace_t structure changed in a binary incompatible way |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
169 when ACL_NO_TRIVIAL etc. were introduced in <sys/acl.h> version 1.15. |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
170 How to distinguish the two conventions at runtime? |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
171 In the old convention, usually three ACEs have a_flags = ACE_OWNER / |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
172 ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400. In the new |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
173 convention, these values are not used. */ |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
174 int old_convention = 0; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
175 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
176 for (i = 0; i < count; i++) |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
177 if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
178 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
179 old_convention = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
180 break; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
181 } |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
182 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
183 if (old_convention) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
184 /* Running on Solaris 10. */ |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
185 for (i = 0; i < count; i++) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
186 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
187 ace_t *ace = &entries[i]; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
188 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
189 /* Note: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
190 If ace->a_flags = ACE_OWNER, ace->a_who is the st_uid from stat(). |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
191 If ace->a_flags = ACE_GROUP, ace->a_who is the st_gid from stat(). |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
192 We don't need to check ace->a_who in these cases. */ |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
193 if (!(ace->a_type == OLD_ALLOW |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
194 && (ace->a_flags == OLD_ACE_OWNER |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
195 || ace->a_flags == OLD_ACE_GROUP |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
196 || ace->a_flags == OLD_ACE_OTHER))) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
197 return 1; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
198 } |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
199 else |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
200 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
201 /* Running on Solaris 10 (newer version) or Solaris 11. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
202 unsigned int access_masks[6] = |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
203 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
204 0, /* owner@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
205 0, /* owner@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
206 0, /* group@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
207 0, /* group@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
208 0, /* everyone@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
209 0 /* everyone@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
210 }; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
211 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
212 for (i = 0; i < count; i++) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
213 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
214 ace_t *ace = &entries[i]; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
215 unsigned int index1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
216 unsigned int index2; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
217 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
218 if (ace->a_type == NEW_ACE_ACCESS_ALLOWED_ACE_TYPE) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
219 index1 = 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
220 else if (ace->a_type == NEW_ACE_ACCESS_DENIED_ACE_TYPE) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
221 index1 = 0; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
222 else |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
223 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
224 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
225 if (ace->a_flags == NEW_ACE_OWNER) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
226 index2 = 0; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
227 else if (ace->a_flags == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
228 index2 = 2; |
15593
270852a80105
acl: Fix compilation on Solaris 10 (older version).
Bruno Haible <bruno@clisp.org>
parents:
15577
diff
changeset
|
229 else if (ace->a_flags == NEW_ACE_EVERYONE) |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
230 index2 = 4; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
231 else |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
232 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
233 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
234 access_masks[index1 + index2] |= ace->a_access_mask; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
235 } |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
236 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
237 /* The same bit shouldn't be both allowed and denied. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
238 if (access_masks[0] & access_masks[1]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
239 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
240 if (access_masks[2] & access_masks[3]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
241 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
242 if (access_masks[4] & access_masks[5]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
243 return 1; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
244 |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
245 /* Check minimum masks. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
246 if ((NEW_ACE_WRITE_NAMED_ATTRS |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
247 | NEW_ACE_WRITE_ATTRIBUTES |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
248 | NEW_ACE_WRITE_ACL |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
249 | NEW_ACE_WRITE_OWNER) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
250 & ~ access_masks[1]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
251 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
252 access_masks[1] &= ~(NEW_ACE_WRITE_NAMED_ATTRS |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
253 | NEW_ACE_WRITE_ATTRIBUTES |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
254 | NEW_ACE_WRITE_ACL |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
255 | NEW_ACE_WRITE_OWNER); |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
256 if ((NEW_ACE_READ_NAMED_ATTRS |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
257 | NEW_ACE_READ_ATTRIBUTES |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
258 | NEW_ACE_READ_ACL |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
259 | NEW_ACE_SYNCHRONIZE) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
260 & ~ access_masks[5]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
261 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
262 access_masks[5] &= ~(NEW_ACE_READ_NAMED_ATTRS |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
263 | NEW_ACE_READ_ATTRIBUTES |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
264 | NEW_ACE_READ_ACL |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
265 | NEW_ACE_SYNCHRONIZE); |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
266 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
267 /* Check the allowed or denied bits. */ |
16380
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
268 switch ((access_masks[0] | access_masks[1]) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
269 & ~(NEW_ACE_READ_NAMED_ATTRS |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
270 | NEW_ACE_READ_ATTRIBUTES |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
271 | NEW_ACE_READ_ACL |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
272 | NEW_ACE_SYNCHRONIZE)) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
273 { |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
274 case 0: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
275 case NEW_ACE_READ_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
276 case NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
277 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
278 case NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
279 case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
280 case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
281 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
282 break; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
283 default: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
284 return 1; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
285 } |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
286 switch ((access_masks[2] | access_masks[3]) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
287 & ~(NEW_ACE_READ_NAMED_ATTRS |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
288 | NEW_ACE_READ_ATTRIBUTES |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
289 | NEW_ACE_READ_ACL |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
290 | NEW_ACE_SYNCHRONIZE)) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
291 { |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
292 case 0: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
293 case NEW_ACE_READ_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
294 case NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
295 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
296 case NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
297 case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
298 case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
299 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
300 break; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
301 default: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
302 return 1; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
303 } |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
304 switch ((access_masks[4] | access_masks[5]) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
305 & ~(NEW_ACE_WRITE_NAMED_ATTRS |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
306 | NEW_ACE_WRITE_ATTRIBUTES |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
307 | NEW_ACE_WRITE_ACL |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
308 | NEW_ACE_WRITE_OWNER)) |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
309 { |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
310 case 0: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
311 case NEW_ACE_READ_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
312 case NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
313 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
314 case NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
315 case NEW_ACE_READ_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
316 case NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
317 case NEW_ACE_READ_DATA | NEW_ACE_WRITEA_DATA | NEW_ACE_EXECUTE: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
318 break; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
319 default: |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
320 return 1; |
1d3faf917922
acl: Fix copy-acl test failure on Solaris 11 2011-11.
Bruno Haible <bruno@clisp.org>
parents:
16343
diff
changeset
|
321 } |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
322 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
323 /* Check that the NEW_ACE_WRITE_DATA and NEW_ACE_APPEND_DATA bits are |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
324 either both allowed or both denied. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
325 if (((access_masks[0] & NEW_ACE_WRITE_DATA) != 0) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
326 != ((access_masks[0] & NEW_ACE_APPEND_DATA) != 0)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
327 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
328 if (((access_masks[2] & NEW_ACE_WRITE_DATA) != 0) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
329 != ((access_masks[2] & NEW_ACE_APPEND_DATA) != 0)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
330 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
331 if (((access_masks[4] & NEW_ACE_WRITE_DATA) != 0) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
332 != ((access_masks[4] & NEW_ACE_APPEND_DATA) != 0)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
333 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
334 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
335 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
336 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
337 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
338 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
339 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
340 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
341 #elif USE_ACL && HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
342 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
343 /* Return 1 if the given ACL is non-trivial. |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
344 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
345 int |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
346 acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
347 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
348 int i; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
349 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
350 for (i = 0; i < count; i++) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
351 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
352 struct acl_entry *ace = &entries[i]; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
353 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
354 if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
355 || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
356 || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
357 return 1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
358 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
359 return 0; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
360 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
361 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
362 # if HAVE_ACLV_H /* HP-UX >= 11.11 */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
363 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
364 /* Return 1 if the given ACL is non-trivial. |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
365 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
366 int |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
367 aclv_nontrivial (int count, struct acl *entries) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
368 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
369 int i; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
370 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
371 for (i = 0; i < count; i++) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
372 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
373 struct acl *ace = &entries[i]; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
374 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
375 /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
376 If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
377 We don't need to check ace->a_id in these cases. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
378 if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
379 || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
380 || ace->a_type == CLASS_OBJ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
381 || ace->a_type == OTHER_OBJ)) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
382 return 1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
383 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
384 return 0; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
385 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
386 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
387 # endif |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
388 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
389 #elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */ |
10183 | 390 |
391 /* Return 1 if the given ACL is non-trivial. | |
392 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | |
393 int | |
394 acl_nontrivial (struct acl *a) | |
395 { | |
396 /* The normal way to iterate through an ACL is like this: | |
397 struct acl_entry *ace; | |
398 for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace)) | |
399 { | |
400 struct ace_id *aei; | |
401 switch (ace->ace_type) | |
402 { | |
403 case ACC_PERMIT: | |
404 case ACC_DENY: | |
405 case ACC_SPECIFY: | |
406 ...; | |
407 } | |
408 for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei)) | |
409 ... | |
410 } | |
411 */ | |
412 return (acl_last (a) != a->acl_ext ? 1 : 0); | |
413 } | |
414 | |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
415 # if HAVE_ACLX_GET && defined ACL_AIX_WIP /* newer AIX */ |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
416 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
417 /* Return 1 if the given ACL is non-trivial. |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
418 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
419 int |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
420 acl_nfs4_nontrivial (nfs4_acl_int_t *a) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
421 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
422 # if 1 /* let's try this first */ |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
423 return (a->aclEntryN > 0 ? 1 : 0); |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
424 # else |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
425 int count = a->aclEntryN; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
426 int i; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
427 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
428 for (i = 0; i < count; i++) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
429 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
430 nfs4_ace_int_t *ace = &a->aclEntry[i]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
431 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
432 if (!((ace->flags & ACE4_ID_SPECIAL) != 0 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
433 && (ace->aceWho.special_whoid == ACE4_WHO_OWNER |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
434 || ace->aceWho.special_whoid == ACE4_WHO_GROUP |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
435 || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
436 && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
437 && ace->aceFlags == 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
438 && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
439 | ACE4_WRITE_DATA | ACE4_ADD_FILE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
440 | ACE4_EXECUTE)) == 0)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
441 return 1; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
442 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
443 return 0; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
444 # endif |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
445 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
446 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
447 # endif |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
448 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
449 #elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
450 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
451 /* Test an ACL retrieved with ACL_GET. |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
452 Return 1 if the given ACL, consisting of COUNT entries, is non-trivial. |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
453 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
454 int |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
455 acl_nontrivial (int count, struct acl *entries) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
456 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
457 int i; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
458 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
459 for (i = 0; i < count; i++) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
460 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
461 struct acl *ace = &entries[i]; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
462 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
463 /* Note: If ace->a_type = USER_OBJ, ace->a_id is the st_uid from stat(). |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
464 If ace->a_type = GROUP_OBJ, ace->a_id is the st_gid from stat(). |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
465 We don't need to check ace->a_id in these cases. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
466 if (!(ace->a_type == USER_OBJ /* no need to check ace->a_id here */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
467 || ace->a_type == GROUP_OBJ /* no need to check ace->a_id here */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
468 || ace->a_type == CLASS_OBJ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
469 || ace->a_type == OTHER_OBJ)) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
470 return 1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
471 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
472 return 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
473 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
474 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
475 #endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
476 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
477 |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
478 /* Return 1 if NAME has a nontrivial access control list, 0 if NAME |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
479 only has no or a base access control list, and -1 (setting errno) |
15814 | 480 on error. SB must be set to the stat buffer of NAME, obtained |
481 through stat() or lstat(). */ | |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
482 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
483 int |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
484 file_has_acl (char const *name, struct stat const *sb) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
485 { |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
486 #if USE_ACL |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
487 if (! S_ISLNK (sb->st_mode)) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
488 { |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
489 # if HAVE_ACL_GET_FILE |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
490 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
491 /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16383
diff
changeset
|
492 /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */ |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
493 int ret; |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
494 |
15825
ab0a4f49f2e8
file-has-acl: revert unintended change in behavior of ls -L
Kamil Dudka <kdudka@redhat.com>
parents:
15814
diff
changeset
|
495 if (HAVE_ACL_EXTENDED_FILE) /* Linux */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
496 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
497 /* On Linux, acl_extended_file is an optimized function: It only |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
498 makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
499 ACL_TYPE_DEFAULT. */ |
15826
23243d868d35
file-has-acl: revert both recent changes, 80af92af and 95f7c57f
Jim Meyering <meyering@redhat.com>
parents:
15825
diff
changeset
|
500 ret = acl_extended_file (name); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
501 } |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16383
diff
changeset
|
502 else /* FreeBSD, Mac OS X, IRIX, Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
503 { |
16935
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16383
diff
changeset
|
504 # if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ |
498a2211d839
Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents:
16383
diff
changeset
|
505 /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
506 and acl_get_file (name, ACL_TYPE_DEFAULT) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
507 always return NULL / EINVAL. There is no point in making |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
508 these two useless calls. The real ACL is retrieved through |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
509 acl_get_file (name, ACL_TYPE_EXTENDED). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
510 acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
511 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
512 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
513 ret = acl_extended_nontrivial (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
514 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
515 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
516 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
517 ret = -1; |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10158
diff
changeset
|
518 # else /* FreeBSD, IRIX, Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
519 acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
520 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
521 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
522 int saved_errno; |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
523 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
524 ret = acl_access_nontrivial (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
525 saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
526 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
527 errno = saved_errno; |
10173
33543159ba5b
Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
528 # if HAVE_ACL_FREE_TEXT /* Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
529 /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
530 returns NULL with errno not set. There is no point in |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
531 making this call. */ |
10173
33543159ba5b
Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
532 # else /* FreeBSD, IRIX */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
533 /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
534 and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
535 either both succeed or both fail; it depends on the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
536 file system. Therefore there is no point in making the second |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
537 call if the first one already failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
538 if (ret == 0 && S_ISDIR (sb->st_mode)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
539 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
540 acl = acl_get_file (name, ACL_TYPE_DEFAULT); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
541 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
542 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
543 ret = (0 < acl_entries (acl)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
544 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
545 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
546 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
547 ret = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
548 } |
10173
33543159ba5b
Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
549 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
550 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
551 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
552 ret = -1; |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10158
diff
changeset
|
553 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
554 } |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
555 if (ret < 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
556 return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1; |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
557 return ret; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
558 |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
559 # elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
560 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
561 # if defined ACL_NO_TRIVIAL |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
562 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
563 /* Solaris 10 (newer version), which has additional API declared in |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
564 <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
565 acl_fromtext, ...). */ |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
566 return acl_trivial (name); |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
567 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
568 # else /* Solaris, Cygwin, general case */ |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
569 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
570 /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
571 of Unixware. The acl() call returns the access and default ACL both |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
572 at once. */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
573 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
574 /* Initially, try to read the entries into a stack-allocated buffer. |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
575 Use malloc if it does not fit. */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
576 enum |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
577 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
578 alloc_init = 4000 / sizeof (aclent_t), /* >= 3 */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
579 alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (aclent_t)) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
580 }; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
581 aclent_t buf[alloc_init]; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
582 size_t alloc = alloc_init; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
583 aclent_t *entries = buf; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
584 aclent_t *malloced = NULL; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
585 int count; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
586 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
587 for (;;) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
588 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
589 count = acl (name, GETACL, alloc, entries); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
590 if (count < 0 && errno == ENOSPC) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
591 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
592 /* Increase the size of the buffer. */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
593 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
594 if (alloc > alloc_max / 2) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
595 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
596 errno = ENOMEM; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
597 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
598 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
599 alloc = 2 * alloc; /* <= alloc_max */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
600 entries = malloced = |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
601 (aclent_t *) malloc (alloc * sizeof (aclent_t)); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
602 if (entries == NULL) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
603 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
604 errno = ENOMEM; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
605 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
606 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
607 continue; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
608 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
609 break; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
610 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
611 if (count < 0) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
612 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
613 if (errno == ENOSYS || errno == ENOTSUP) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
614 ; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
615 else |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
616 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
617 int saved_errno = errno; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
618 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
619 errno = saved_errno; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
620 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
621 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
622 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
623 else if (count == 0) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
624 ; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
625 else |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
626 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
627 /* Don't use MIN_ACL_ENTRIES: It's set to 4 on Cygwin, but Cygwin |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
628 returns only 3 entries for files with no ACL. But this is safe: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
629 If there are more than 4 entries, there cannot be only the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
630 "user::", "group::", "other:", and "mask:" entries. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
631 if (count > 4) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
632 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
633 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
634 return 1; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
635 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
636 |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
637 if (acl_nontrivial (count, entries)) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
638 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
639 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
640 return 1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
641 } |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
642 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
643 free (malloced); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
644 } |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
645 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
646 # ifdef ACE_GETACL |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
647 /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
648 file systems (whereas the other ones are used in UFS file systems). */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
649 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
650 /* Initially, try to read the entries into a stack-allocated buffer. |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
651 Use malloc if it does not fit. */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
652 enum |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
653 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
654 alloc_init = 4000 / sizeof (ace_t), /* >= 3 */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
655 alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (ace_t)) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
656 }; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
657 ace_t buf[alloc_init]; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
658 size_t alloc = alloc_init; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
659 ace_t *entries = buf; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
660 ace_t *malloced = NULL; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
661 int count; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
662 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
663 for (;;) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
664 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
665 count = acl (name, ACE_GETACL, alloc, entries); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
666 if (count < 0 && errno == ENOSPC) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
667 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
668 /* Increase the size of the buffer. */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
669 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
670 if (alloc > alloc_max / 2) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
671 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
672 errno = ENOMEM; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
673 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
674 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
675 alloc = 2 * alloc; /* <= alloc_max */ |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
676 entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t)); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
677 if (entries == NULL) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
678 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
679 errno = ENOMEM; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
680 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
681 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
682 continue; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
683 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
684 break; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
685 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
686 if (count < 0) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
687 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
688 if (errno == ENOSYS || errno == EINVAL) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
689 ; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
690 else |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
691 { |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
692 int saved_errno = errno; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
693 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
694 errno = saved_errno; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
695 return -1; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
696 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
697 } |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
698 else if (count == 0) |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
699 ; |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
700 else |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
701 { |
15571
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
702 /* In the old (original Solaris 10) convention: |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
703 If there are more than 3 entries, there cannot be only the |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
704 ACE_OWNER, ACE_GROUP, ACE_OTHER entries. |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
705 In the newer Solaris 10 and Solaris 11 convention: |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
706 If there are more than 6 entries, there cannot be only the |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
707 ACE_OWNER, ACE_GROUP, ACE_EVERYONE entries, each once with |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
708 NEW_ACE_ACCESS_ALLOWED_ACE_TYPE and once with |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
709 NEW_ACE_ACCESS_DENIED_ACE_TYPE. */ |
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
710 if (count > 6) |
16381
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16380
diff
changeset
|
711 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
712 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
713 return 1; |
16381
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16380
diff
changeset
|
714 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
715 |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
716 if (acl_ace_nontrivial (count, entries)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
717 { |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
718 free (malloced); |
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
719 return 1; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
720 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
721 } |
16382
cc05dad27529
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16381
diff
changeset
|
722 free (malloced); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
723 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
724 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
725 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
726 return 0; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
727 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
728 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
729 # elif HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
730 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
731 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
732 struct acl_entry entries[NACLENTRIES]; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
733 int count; |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
734 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
735 count = getacl (name, NACLENTRIES, entries); |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
736 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
737 if (count < 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
738 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
739 /* ENOSYS is seen on newer HP-UX versions. |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
740 EOPNOTSUPP is typically seen on NFS mounts. |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
741 ENOTSUP was seen on Quantum StorNext file systems (cvfs). */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
742 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
743 ; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
744 else |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
745 return -1; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
746 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
747 else if (count == 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
748 return 0; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
749 else /* count > 0 */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
750 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
751 if (count > NACLENTRIES) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
752 /* If NACLENTRIES cannot be trusted, use dynamic memory |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
753 allocation. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
754 abort (); |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
755 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
756 /* If there are more than 3 entries, there cannot be only the |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
757 (uid,%), (%,gid), (%,%) entries. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
758 if (count > 3) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
759 return 1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
760 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
761 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
762 struct stat statbuf; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
763 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
764 if (stat (name, &statbuf) < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
765 return -1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
766 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
767 return acl_nontrivial (count, entries, &statbuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
768 } |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
769 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
770 } |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
771 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
772 # if HAVE_ACLV_H /* HP-UX >= 11.11 */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
773 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
774 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
775 struct acl entries[NACLVENTRIES]; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
776 int count; |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
777 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
778 count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries); |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
779 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
780 if (count < 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
781 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
782 /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23. |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
783 EINVAL is seen on NFS in HP-UX 11.31. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
784 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
785 ; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
786 else |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
787 return -1; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
788 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
789 else if (count == 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
790 return 0; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
791 else /* count > 0 */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
792 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
793 if (count > NACLVENTRIES) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
794 /* If NACLVENTRIES cannot be trusted, use dynamic memory |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
795 allocation. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
796 abort (); |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
797 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
798 /* If there are more than 4 entries, there cannot be only the |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
799 four base ACL entries. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
800 if (count > 4) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
801 return 1; |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
802 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
803 return aclv_nontrivial (count, entries); |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
804 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
805 } |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
806 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
807 # endif |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
808 |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
809 # elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */ |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
810 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
811 acl_type_t type; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
812 char aclbuf[1024]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
813 void *acl = aclbuf; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
814 size_t aclsize = sizeof (aclbuf); |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
815 mode_t mode; |
10183 | 816 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
817 for (;;) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
818 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
819 /* The docs say that type being 0 is equivalent to ACL_ANY, but it |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
820 is not true, in AIX 5.3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
821 type.u64 = ACL_ANY; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
822 if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
823 break; |
15577
15d6c13d7aae
acl: Update for AIX >= 5.3 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15573
diff
changeset
|
824 if (errno == ENOSYS) |
15d6c13d7aae
acl: Update for AIX >= 5.3 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15573
diff
changeset
|
825 return 0; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
826 if (errno != ENOSPC) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
827 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
828 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
829 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
830 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
831 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
832 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
833 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
834 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
835 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
836 aclsize = 2 * aclsize; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
837 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
838 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
839 acl = malloc (aclsize); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
840 if (acl == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
841 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
842 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
843 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
844 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
845 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
846 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
847 if (type.u64 == ACL_AIXC) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
848 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
849 int result = acl_nontrivial ((struct acl *) acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
850 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
851 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
852 return result; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
853 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
854 else if (type.u64 == ACL_NFS4) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
855 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
856 int result = acl_nfs4_nontrivial ((nfs4_acl_int_t *) acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
857 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
858 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
859 return result; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
860 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
861 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
862 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
863 /* A newer type of ACL has been introduced in the system. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
864 We should better support it. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
865 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
866 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
867 errno = EINVAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
868 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
869 } |
10183 | 870 |
871 # elif HAVE_STATACL /* older AIX */ | |
872 | |
873 union { struct acl a; char room[4096]; } u; | |
874 | |
875 if (statacl (name, STX_NORMAL, &u.a, sizeof (u)) < 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
876 return -1; |
10183 | 877 |
878 return acl_nontrivial (&u.a); | |
879 | |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
880 # elif HAVE_ACLSORT /* NonStop Kernel */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
881 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
882 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
883 struct acl entries[NACLENTRIES]; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
884 int count; |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
885 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
886 count = acl ((char *) name, ACL_GET, NACLENTRIES, entries); |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
887 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
888 if (count < 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
889 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
890 if (errno == ENOSYS || errno == ENOTSUP) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
891 ; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
892 else |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
893 return -1; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
894 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
895 else if (count == 0) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
896 return 0; |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
897 else /* count > 0 */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
898 { |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
899 if (count > NACLENTRIES) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
900 /* If NACLENTRIES cannot be trusted, use dynamic memory |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
901 allocation. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
902 abort (); |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
903 |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
904 /* If there are more than 4 entries, there cannot be only the |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
905 four base ACL entries. */ |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
906 if (count > 4) |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
907 return 1; |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
908 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
909 return acl_nontrivial (count, entries); |
16383
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
910 } |
531aa00a1e80
acl: Don't use ACL_CNT and similar ops, since they are unreliable.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16382
diff
changeset
|
911 } |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
912 |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
913 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
914 } |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
915 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
916 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
917 return 0; |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
918 } |