Mercurial > hg > octave-shane > gnulib-hg
annotate lib/file-has-acl.c @ 15572:dd7c06a51643
acl: Clean up Solaris code.
* lib/acl-internal.h: Remove no-op #if.
* lib/file-has-acl.c: Likewise.
* lib/set-mode-acl.c (qset_acl): Remove unused Solaris code.
* lib/copy-acl.c (qcopy_acl): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 06 Sep 2011 00:26:07 +0200 |
parents | 5d1d1c0b8204 |
children | 132ec6dff66c |
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 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13757
diff
changeset
|
3 Copyright (C) 2002-2003, 2005-2011 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 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 #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
|
21 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 #include "acl.h" |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
23 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
24 #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
|
25 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
26 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
27 #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
|
28 |
10177
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
29 # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
30 |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
31 /* 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
|
32 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
|
33 Return 0 if it is trivial. */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
34 int |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
35 acl_extended_nontrivial (acl_t acl) |
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 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
|
38 return (acl_entries (acl) > 0); |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
39 } |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
40 |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
41 # else /* Linux, FreeBSD, IRIX, Tru64 */ |
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
42 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
43 /* 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
|
44 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
|
45 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
|
46 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
|
47 int |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
48 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
|
49 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
50 /* 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
|
51 "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
|
52 at least, allowing us to write |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
53 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
|
54 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
|
55 # 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
|
56 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
57 acl_entry_t ace; |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
58 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
|
59 |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
60 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
|
61 got_one > 0; |
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
62 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
|
63 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 } |
11546
03ef9ae804c9
acl: Fix infinite loop on FreeBSD.
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
10191
diff
changeset
|
70 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
|
71 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
72 # 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
|
73 # 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
|
74 /* 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
|
75 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
76 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
|
77 int i; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
78 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
79 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
|
80 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
81 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
|
82 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
|
83 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
84 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
|
85 || tag == ACL_OTHER_OBJ)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
86 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
|
87 } |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
88 return 0; |
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 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
91 # 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
|
92 /* 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
|
93 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
94 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
|
95 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
|
96 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
97 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
|
98 { |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
99 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
|
100 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
|
101 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
106 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
|
107 /* 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
|
108 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
|
109 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
|
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 return 0; |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
113 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
114 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
115 # endif |
10177
caed32fb1892
New function acl_extended_nontrivial (MacOS X only).
Bruno Haible <bruno@clisp.org>
parents:
10175
diff
changeset
|
116 } |
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 # endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
119 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
120 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
121 #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
|
122 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
123 /* Test an ACL retrieved with GETACL. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
124 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
|
125 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
|
126 int |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
127 acl_nontrivial (int count, aclent_t *entries) |
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 int i; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
130 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
131 for (i = 0; i < count; i++) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
132 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
133 aclent_t *ace = &entries[i]; |
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 /* 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
|
136 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
|
137 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
|
138 if (!(ace->a_type == USER_OBJ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
139 || ace->a_type == GROUP_OBJ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
140 || ace->a_type == OTHER_OBJ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
141 /* 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
|
142 sometimes. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
143 || ace->a_type == CLASS_OBJ)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
144 return 1; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
145 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
146 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
147 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
148 |
15572
dd7c06a51643
acl: Clean up Solaris code.
Bruno Haible <bruno@clisp.org>
parents:
15571
diff
changeset
|
149 # ifdef ACE_GETACL |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
150 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
151 /* Test an ACL retrieved with ACE_GETACL. |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
152 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
|
153 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
|
154 int |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
155 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
|
156 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
157 int i; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
158 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
159 /* 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 int old_convention = 0; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
166 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
167 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
|
168 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
|
169 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
170 old_convention = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
171 break; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
172 } |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
173 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
174 if (old_convention) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
175 /* Running on Solaris 10. */ |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
176 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
|
177 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
178 ace_t *ace = &entries[i]; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
179 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
180 /* Note: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 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
|
185 && (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
|
186 || 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
|
187 || ace->a_flags == OLD_ACE_OTHER))) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
188 return 1; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
189 } |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
190 else |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
191 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
192 /* 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
|
193 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
|
194 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
195 0, /* owner@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
196 0, /* owner@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
197 0, /* group@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
198 0, /* group@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
199 0, /* everyone@ deny */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
200 0 /* everyone@ allow */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
201 }; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
202 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
203 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
|
204 { |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
205 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
|
206 unsigned int index1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
207 unsigned int index2; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
208 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
209 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
|
210 index1 = 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
211 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
|
212 index1 = 0; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
213 else |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
214 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
215 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
216 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
|
217 index2 = 0; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
218 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
|
219 index2 = 2; |
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_flags == ACE_EVERYONE) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
221 index2 = 4; |
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 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
|
226 } |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
227 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
228 /* 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
|
229 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
|
230 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
231 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
|
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 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
|
234 return 1; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
235 |
15570
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
236 /* Check minimum masks. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
237 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
|
238 | 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
|
239 | 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
|
240 | 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
|
241 & ~ access_masks[1]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
242 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
243 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
|
244 | 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
|
245 | 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
|
246 | 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
|
247 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 & ~ access_masks[4]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
252 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
253 access_masks[4] &= ~(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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 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
|
258 | 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
|
259 | 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
|
260 | NEW_ACE_SYNCHRONIZE) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
261 & ~ access_masks[5]) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
262 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
263 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
|
264 | 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
|
265 | 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
|
266 | NEW_ACE_SYNCHRONIZE); |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
267 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
268 /* Check the allowed or denied bits. */ |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
269 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
|
270 != (NEW_ACE_READ_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
271 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
272 | NEW_ACE_EXECUTE)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
273 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
274 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
|
275 != (NEW_ACE_READ_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
276 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
277 | NEW_ACE_EXECUTE)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
278 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
279 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
|
280 != (NEW_ACE_READ_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
281 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
282 | NEW_ACE_EXECUTE)) |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
283 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
284 |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
285 /* 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
|
286 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
|
287 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
|
288 != ((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
|
289 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
290 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
|
291 != ((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
|
292 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
293 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
|
294 != ((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
|
295 return 1; |
cd0bdf15a524
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15439
diff
changeset
|
296 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
297 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
298 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
299 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
300 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
301 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
302 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
303 #elif USE_ACL && HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
304 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
305 /* 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
|
306 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
|
307 int |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
308 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
|
309 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
310 int i; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
311 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
312 for (i = 0; i < count; i++) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
313 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
314 struct acl_entry *ace = &entries[i]; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
315 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
316 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
|
317 || (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
|
318 || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP))) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
319 return 1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
320 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
321 return 0; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
322 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
323 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
324 # 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
|
325 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
326 /* 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
|
327 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
|
328 int |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
329 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
|
330 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
331 int i; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
332 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
333 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
|
334 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
335 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
|
336 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
337 /* 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
|
338 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
|
339 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
|
340 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
|
341 || 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
|
342 || 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
|
343 || 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
|
344 return 1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
345 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
346 return 0; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
347 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
348 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
349 # endif |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
350 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
351 #elif USE_ACL && (HAVE_ACLX_GET || HAVE_STATACL) /* AIX */ |
10183 | 352 |
353 /* Return 1 if the given ACL is non-trivial. | |
354 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ | |
355 int | |
356 acl_nontrivial (struct acl *a) | |
357 { | |
358 /* The normal way to iterate through an ACL is like this: | |
359 struct acl_entry *ace; | |
360 for (ace = a->acl_ext; ace != acl_last (a); ace = acl_nxt (ace)) | |
361 { | |
362 struct ace_id *aei; | |
363 switch (ace->ace_type) | |
364 { | |
365 case ACC_PERMIT: | |
366 case ACC_DENY: | |
367 case ACC_SPECIFY: | |
368 ...; | |
369 } | |
370 for (aei = ace->ace_id; aei != id_last (ace); aei = id_nxt (aei)) | |
371 ... | |
372 } | |
373 */ | |
374 return (acl_last (a) != a->acl_ext ? 1 : 0); | |
375 } | |
376 | |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
377 # 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
|
378 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
379 /* 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
|
380 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
|
381 int |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
382 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
|
383 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
384 # 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
|
385 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
|
386 # else |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
387 int count = a->aclEntryN; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
388 int i; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
389 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
390 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
|
391 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
392 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
|
393 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
394 if (!((ace->flags & ACE4_ID_SPECIAL) != 0 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
395 && (ace->aceWho.special_whoid == ACE4_WHO_OWNER |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
396 || ace->aceWho.special_whoid == ACE4_WHO_GROUP |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
397 || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
398 && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
399 && ace->aceFlags == 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
400 && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
401 | ACE4_WRITE_DATA | ACE4_ADD_FILE |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
402 | ACE4_EXECUTE)) == 0)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
403 return 1; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
404 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
405 return 0; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
406 # endif |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
407 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
408 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
409 # endif |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
410 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
411 #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
|
412 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
413 /* 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
|
414 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
|
415 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
|
416 int |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
417 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
|
418 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
419 int i; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
420 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
421 for (i = 0; i < count; i++) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
422 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
423 struct acl *ace = &entries[i]; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
424 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
425 /* 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
|
426 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
|
427 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
|
428 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
|
429 || 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
|
430 || ace->a_type == CLASS_OBJ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
431 || ace->a_type == OTHER_OBJ)) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
432 return 1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
433 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
434 return 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
435 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
436 |
10158
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
437 #endif |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
438 |
73042342e7f6
New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents:
10155
diff
changeset
|
439 |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
440 /* 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
|
441 only has no or a base access control list, and -1 (setting errno) |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
442 on error. SB must be set to the stat buffer of FILE. */ |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
443 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
444 int |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
445 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
|
446 { |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
447 #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
|
448 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
|
449 { |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
450 # 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
|
451 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
452 /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ |
10114
51164d97e89b
Make copy_acl work on MacOS X 10.5.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
453 /* Linux, FreeBSD, MacOS 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
|
454 int ret; |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
455 |
15439
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
456 if (HAVE_ACL_EXTENDED_FILE || HAVE_ACL_EXTENDED_FILE_NOFOLLOW) /* Linux */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
457 { |
15439
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
458 # if HAVE_ACL_EXTENDED_FILE_NOFOLLOW |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
459 /* acl_extended_file_nofollow() uses lgetxattr() in order to prevent |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
460 unnecessary mounts, but it returns the same result as we already |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
461 know that NAME is not a symbolic link at this point (modulo the |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
462 TOCTTOU race condition). */ |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
463 ret = acl_extended_file_nofollow (name); |
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
464 # else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
465 /* 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
|
466 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
|
467 ACL_TYPE_DEFAULT. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
468 ret = acl_extended_file (name); |
15439
12875e5545b9
file-has-acl: use acl_extended_file_nofollow if available
Kamil Dudka <kdudka@redhat.com>
parents:
14905
diff
changeset
|
469 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
470 } |
10175 | 471 else /* FreeBSD, MacOS X, IRIX, Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
472 { |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10158
diff
changeset
|
473 # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
474 /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
475 and acl_get_file (name, ACL_TYPE_DEFAULT) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
476 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
|
477 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
|
478 acl_get_file (name, ACL_TYPE_EXTENDED). */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
479 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
|
480 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
481 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
482 ret = acl_extended_nontrivial (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
483 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
484 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
485 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
486 ret = -1; |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10158
diff
changeset
|
487 # else /* FreeBSD, IRIX, Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
488 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
|
489 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
490 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
491 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
|
492 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
493 ret = acl_access_nontrivial (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
494 saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
495 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
496 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
|
497 # if HAVE_ACL_FREE_TEXT /* Tru64 */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
498 /* 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
|
499 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
|
500 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
|
501 # else /* FreeBSD, IRIX */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
502 /* 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
|
503 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
|
504 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
|
505 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
|
506 call if the first one already failed. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
507 if (ret == 0 && S_ISDIR (sb->st_mode)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
508 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
509 acl = acl_get_file (name, ACL_TYPE_DEFAULT); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
510 if (acl) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
511 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
512 ret = (0 < acl_entries (acl)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
513 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
514 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
515 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
516 ret = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
517 } |
10173
33543159ba5b
Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
518 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
519 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
520 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
521 ret = -1; |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10158
diff
changeset
|
522 # endif |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
523 } |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
524 if (ret < 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
525 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
|
526 return ret; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
527 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
528 # elif HAVE_FACL && defined GETACLCNT /* 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
|
529 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10185
diff
changeset
|
530 # 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
|
531 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
532 /* 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
|
533 <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
|
534 acl_fromtext, ...). */ |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
535 return acl_trivial (name); |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
536 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
537 # else /* Solaris, Cygwin, general case */ |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
538 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
539 /* 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
|
540 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
|
541 at once. */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
542 int count; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
543 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
544 aclent_t *entries; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
545 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
546 for (;;) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
547 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
548 count = acl (name, GETACLCNT, 0, NULL); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
549 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
550 if (count < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
551 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
552 if (errno == ENOSYS || errno == ENOTSUP) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
553 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
554 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
555 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
556 } |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
557 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
558 if (count == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
559 break; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
560 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
561 /* 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
|
562 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
|
563 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
|
564 "user::", "group::", "other:", and "mask:" entries. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
565 if (count > 4) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
566 return 1; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
567 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
568 entries = (aclent_t *) malloc (count * sizeof (aclent_t)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
569 if (entries == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
570 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
571 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
572 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
573 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
574 if (acl (name, GETACL, count, entries) == count) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
575 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
576 if (acl_nontrivial (count, entries)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
577 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
578 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
579 return 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
580 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
581 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
582 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
583 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
584 /* Huh? The number of ACL entries changed since the last call. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
585 Repeat. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
586 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
587 } |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
588 } |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
589 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
590 # ifdef ACE_GETACL |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
591 /* 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
|
592 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
|
593 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
594 ace_t *entries; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
595 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
596 for (;;) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
597 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
598 count = acl (name, ACE_GETACLCNT, 0, NULL); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
599 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
600 if (count < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
601 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
602 if (errno == ENOSYS || errno == EINVAL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
603 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
604 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
605 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
606 } |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
607 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
608 if (count == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
609 break; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
610 |
15571
5d1d1c0b8204
acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
15570
diff
changeset
|
611 /* 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
|
612 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
|
613 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
|
614 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
|
615 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
|
616 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
|
617 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
|
618 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
|
619 if (count > 6) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
620 return 1; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
621 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
622 entries = (ace_t *) malloc (count * sizeof (ace_t)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
623 if (entries == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
624 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
625 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
626 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
627 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
628 if (acl (name, ACE_GETACL, count, entries) == count) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
629 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
630 if (acl_ace_nontrivial (count, entries)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
631 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
632 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
633 return 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
634 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
635 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
636 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
637 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
638 /* Huh? The number of ACL entries changed since the last call. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
639 Repeat. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
640 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
641 } |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
642 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
643 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
644 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10177
diff
changeset
|
645 return 0; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
646 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
647 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
648 # elif HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
649 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
650 for (;;) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
651 { |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
652 int count; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
653 struct acl_entry entries[NACLENTRIES]; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
654 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
655 count = getacl (name, 0, NULL); |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
656 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
657 if (count < 0) |
14904
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
658 { |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
659 /* ENOSYS is seen on newer HP-UX versions. |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
660 EOPNOTSUPP is typically seen on NFS mounts. |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
661 ENOTSUP was seen on Quantum StorNext file systems (cvfs). */ |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
662 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
663 break; |
14904
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
664 else |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
665 return -1; |
812be65b0e8b
acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
666 } |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
667 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
668 if (count == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
669 return 0; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
670 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
671 if (count > NACLENTRIES) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
672 /* If NACLENTRIES cannot be trusted, use dynamic memory |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
673 allocation. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
674 abort (); |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
675 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
676 /* If there are more than 3 entries, there cannot be only the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
677 (uid,%), (%,gid), (%,%) entries. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
678 if (count > 3) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
679 return 1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
680 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
681 if (getacl (name, count, entries) == count) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
682 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
683 struct stat statbuf; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
684 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
685 if (stat (name, &statbuf) < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
686 return -1; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
687 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
688 return acl_nontrivial (count, entries, &statbuf); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
689 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
690 /* Huh? The number of ACL entries changed since the last call. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
691 Repeat. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
692 } |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
693 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
694 # 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
|
695 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
696 for (;;) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
697 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
698 int count; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
699 struct acl entries[NACLVENTRIES]; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
700 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
701 count = acl ((char *) name, ACL_CNT, NACLVENTRIES, entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
702 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
703 if (count < 0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
704 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
705 /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23. |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
706 EINVAL is seen on NFS in HP-UX 11.31. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
707 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
708 break; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
709 else |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
710 return -1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
711 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
712 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
713 if (count == 0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
714 return 0; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
715 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
716 if (count > NACLVENTRIES) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
717 /* If NACLVENTRIES cannot be trusted, use dynamic memory |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
718 allocation. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
719 abort (); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
720 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
721 /* If there are more than 4 entries, there cannot be only the |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
722 four base ACL entries. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
723 if (count > 4) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
724 return 1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
725 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
726 if (acl ((char *) name, ACL_GET, count, entries) == count) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
727 return aclv_nontrivial (count, entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
728 /* Huh? The number of ACL entries changed since the last call. |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
729 Repeat. */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
730 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
731 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
732 # endif |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
733 |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
734 # 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
|
735 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
736 acl_type_t type; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
737 char aclbuf[1024]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
738 void *acl = aclbuf; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
739 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
|
740 mode_t mode; |
10183 | 741 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
742 for (;;) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
743 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
744 /* 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
|
745 is not true, in AIX 5.3. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
746 type.u64 = ACL_ANY; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
747 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
|
748 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
749 if (errno != ENOSPC) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
750 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
751 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
752 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
753 int saved_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
754 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
755 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
756 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
757 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
758 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
759 aclsize = 2 * aclsize; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
760 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
761 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
762 acl = malloc (aclsize); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
763 if (acl == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
764 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
765 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
766 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
767 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
768 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
769 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
770 if (type.u64 == ACL_AIXC) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
771 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
772 int result = acl_nontrivial ((struct acl *) acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
773 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
774 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
775 return result; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
776 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
777 else if (type.u64 == ACL_NFS4) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
778 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
779 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
|
780 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
781 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
782 return result; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
783 } |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11546
diff
changeset
|
784 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
785 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
786 /* 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
|
787 We should better support it. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
788 if (acl != aclbuf) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
789 free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
790 errno = EINVAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
791 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12146
diff
changeset
|
792 } |
10183 | 793 |
794 # elif HAVE_STATACL /* older AIX */ | |
795 | |
796 union { struct acl a; char room[4096]; } u; | |
797 | |
798 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
|
799 return -1; |
10183 | 800 |
801 return acl_nontrivial (&u.a); | |
802 | |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
803 # elif HAVE_ACLSORT /* NonStop Kernel */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
804 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
805 int count; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
806 struct acl entries[NACLENTRIES]; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
807 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
808 for (;;) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
809 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
810 count = acl ((char *) name, ACL_CNT, NACLENTRIES, NULL); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
811 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
812 if (count < 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
813 return -1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
814 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
815 if (count == 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
816 return 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
817 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
818 if (count > NACLENTRIES) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
819 /* If NACLENTRIES cannot be trusted, use dynamic memory |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
820 allocation. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
821 abort (); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
822 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
823 /* If there are more than 4 entries, there cannot be only the |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
824 four base ACL entries. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
825 if (count > 4) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
826 return 1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
827 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
828 if (acl ((char *) name, ACL_GET, count, entries) == count) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
829 return acl_nontrivial (count, entries); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
830 /* Huh? The number of ACL entries changed since the last call. |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
831 Repeat. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
832 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
833 |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
834 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10114
diff
changeset
|
835 } |
8476
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
836 #endif |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
837 |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
838 return 0; |
2798cb65bd90
Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
839 } |