annotate lib/file-has-acl.c @ 16381:fc5c37ccbece

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