annotate lib/file-has-acl.c @ 16343:3bec4206b1cc

file-has-acl: suppress a warning from gcc -Wsuggest-attribute=const * lib/file-has-acl.c (file_has_acl): This function (for some #ifdefs) would evoke a new gcc warning. Given all of the #ifdefs, it is better not even to try to add the attribute. Instead, add a pragma to suppress the suggestion/warning.
author Jim Meyering <meyering@redhat.com>
date Thu, 02 Feb 2012 09:12:13 +0100
parents 8250f2777afc
children 1d3faf917922
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
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
157 /* Test an ACL retrieved with ACE_GETACL.
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
158 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
159 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
160 int
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
161 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
162 {
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
163 int i;
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
164
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
165 /* 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
166 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
167 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
168 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
169 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
170 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
171 int old_convention = 0;
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
172
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
173 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
174 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
175 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
176 old_convention = 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
177 break;
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
178 }
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
179
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
180 if (old_convention)
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
181 /* Running on Solaris 10. */
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
182 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
183 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
184 ace_t *ace = &entries[i];
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
185
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
186 /* Note:
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
187 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
188 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
189 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
190 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
191 && (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
192 || 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
193 || ace->a_flags == OLD_ACE_OTHER)))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
194 return 1;
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
195 }
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
196 else
15570
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
197 {
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
198 /* 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
199 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
200 {
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
201 0, /* owner@ deny */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
202 0, /* owner@ allow */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
203 0, /* group@ deny */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
204 0, /* group@ allow */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
205 0, /* everyone@ deny */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
206 0 /* everyone@ allow */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
207 };
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
208
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
209 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
210 {
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
211 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
212 unsigned int index1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
213 unsigned int index2;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
214
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
215 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
216 index1 = 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
217 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
218 index1 = 0;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
219 else
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
220 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
221
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
222 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
223 index2 = 0;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
224 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
225 index2 = 2;
15593
270852a80105 acl: Fix compilation on Solaris 10 (older version).
Bruno Haible <bruno@clisp.org>
parents: 15577
diff changeset
226 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
227 index2 = 4;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
228 else
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
229 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
230
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
231 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
232 }
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 /* 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
235 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
236 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
237 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
238 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
239 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
240 return 1;
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
241
15570
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
242 /* Check minimum masks. */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
243 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
244 | NEW_ACE_WRITE_ATTRIBUTES
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
245 | NEW_ACE_WRITE_ACL
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
246 | NEW_ACE_WRITE_OWNER)
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
247 & ~ access_masks[1])
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
248 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
249 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
250 | 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
251 | 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
252 | 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
253 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
254 | NEW_ACE_WRITE_ATTRIBUTES
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
255 | NEW_ACE_WRITE_ACL
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
256 | NEW_ACE_WRITE_OWNER)
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
257 & ~ access_masks[4])
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
258 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
259 access_masks[4] &= ~(NEW_ACE_WRITE_NAMED_ATTRS
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
260 | 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
261 | 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
262 | 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
263 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
264 | NEW_ACE_READ_ATTRIBUTES
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
265 | NEW_ACE_READ_ACL
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
266 | NEW_ACE_SYNCHRONIZE)
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
267 & ~ access_masks[5])
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
268 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
269 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
270 | 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
271 | 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
272 | NEW_ACE_SYNCHRONIZE);
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
273
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
274 /* Check the allowed or denied bits. */
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
275 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
276 != (NEW_ACE_READ_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
277 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
278 | NEW_ACE_EXECUTE))
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
279 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
280 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
281 != (NEW_ACE_READ_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
282 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
283 | NEW_ACE_EXECUTE))
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
284 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
285 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
286 != (NEW_ACE_READ_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
287 | NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
288 | NEW_ACE_EXECUTE))
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
289 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
290
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
291 /* 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
292 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
293 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
294 != ((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
295 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
296 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
297 != ((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
298 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
299 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
300 != ((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
301 return 1;
cd0bdf15a524 acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15439
diff changeset
302 }
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
303
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
304 return 0;
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
305 }
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
306
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
307 # endif
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
308
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
309 #elif USE_ACL && HAVE_GETACL /* HP-UX */
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
310
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
311 /* 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
312 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
313 int
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
314 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
315 {
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
316 int i;
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
317
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
318 for (i = 0; i < count; i++)
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
319 {
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
320 struct acl_entry *ace = &entries[i];
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
321
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
322 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
323 || (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
324 || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
325 return 1;
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
326 }
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
327 return 0;
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
328 }
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
329
14905
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
330 # 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
331
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
332 /* 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
333 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
334 int
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
335 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
336 {
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
337 int i;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
338
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
339 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
340 {
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
341 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
342
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
343 /* 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
344 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
345 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
346 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
347 || 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
348 || 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
349 || 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
350 return 1;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
351 }
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
352 return 0;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
353 }
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
354
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
355 # endif
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
356
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
357 #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
358
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
359 /* Return 1 if the given ACL is non-trivial.
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
360 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
361 int
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
362 acl_nontrivial (struct acl *a)
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
363 {
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
364 /* 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
365 struct acl_entry *ace;
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
366 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
367 {
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
368 struct ace_id *aei;
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
369 switch (ace->ace_type)
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
370 {
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
371 case ACC_PERMIT:
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
372 case ACC_DENY:
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
373 case ACC_SPECIFY:
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
374 ...;
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
375 }
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
376 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
377 ...
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
378 }
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
379 */
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
380 return (acl_last (a) != a->acl_ext ? 1 : 0);
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
381 }
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
382
12077
72b0c1288a50 Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents: 12075
diff changeset
383 # 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
384
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
385 /* 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
386 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
387 int
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
388 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
389 {
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
390 # 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
391 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
392 # else
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
393 int count = a->aclEntryN;
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
394 int i;
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
395
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
396 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
397 {
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
398 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
399
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
400 if (!((ace->flags & ACE4_ID_SPECIAL) != 0
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
401 && (ace->aceWho.special_whoid == ACE4_WHO_OWNER
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
402 || ace->aceWho.special_whoid == ACE4_WHO_GROUP
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
403 || ace->aceWho.special_whoid == ACE4_WHO_EVERYONE)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
404 && ace->aceType == ACE4_ACCESS_ALLOWED_ACE_TYPE
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
405 && ace->aceFlags == 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
406 && (ace->aceMask & ~(ACE4_READ_DATA | ACE4_LIST_DIRECTORY
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
407 | ACE4_WRITE_DATA | ACE4_ADD_FILE
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
408 | ACE4_EXECUTE)) == 0))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
409 return 1;
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
410 }
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
411 return 0;
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
412 # endif
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
413 }
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
414
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
415 # endif
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
416
13757
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
417 #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
418
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
419 /* 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
420 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
421 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
422 int
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
423 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
424 {
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
425 int i;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
426
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
427 for (i = 0; i < count; i++)
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
428 {
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
429 struct acl *ace = &entries[i];
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
430
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
431 /* 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
432 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
433 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
434 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
435 || 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
436 || ace->a_type == CLASS_OBJ
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
437 || ace->a_type == OTHER_OBJ))
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
438 return 1;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
439 }
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
440 return 0;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
441 }
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
442
10158
73042342e7f6 New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents: 10155
diff changeset
443 #endif
73042342e7f6 New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents: 10155
diff changeset
444
73042342e7f6 New function for testing triviality of ACL with POSIX-draft like API.
Bruno Haible <bruno@clisp.org>
parents: 10155
diff changeset
445
8476
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
446 /* 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
447 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
448 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
449 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
450
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
451 int
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
452 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
453 {
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
454 #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
455 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
456 {
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
457 # 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
458
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
459 /* 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
460 /* 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
461 int ret;
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
462
15825
ab0a4f49f2e8 file-has-acl: revert unintended change in behavior of ls -L
Kamil Dudka <kdudka@redhat.com>
parents: 15814
diff changeset
463 if (HAVE_ACL_EXTENDED_FILE) /* Linux */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
464 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
465 /* On Linux, acl_extended_file is an optimized function: It only
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
466 makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
467 ACL_TYPE_DEFAULT. */
15826
23243d868d35 file-has-acl: revert both recent changes, 80af92af and 95f7c57f
Jim Meyering <meyering@redhat.com>
parents: 15825
diff changeset
468 ret = acl_extended_file (name);
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
469 }
10175
ed86dd8c386e Comments.
Bruno Haible <bruno@clisp.org>
parents: 10173
diff changeset
470 else /* FreeBSD, MacOS X, IRIX, Tru64 */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
471 {
10172
50e666f281ef Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10158
diff changeset
472 # if HAVE_ACL_TYPE_EXTENDED /* MacOS X */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
473 /* 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
474 and acl_get_file (name, ACL_TYPE_DEFAULT)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
475 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
476 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
477 acl_get_file (name, ACL_TYPE_EXTENDED). */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
478 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
479 if (acl)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
480 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
481 ret = acl_extended_nontrivial (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
482 acl_free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
483 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
484 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
485 ret = -1;
10172
50e666f281ef Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10158
diff changeset
486 # else /* FreeBSD, IRIX, Tru64 */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
487 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
488 if (acl)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
489 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
490 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
491
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
492 ret = acl_access_nontrivial (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
493 saved_errno = errno;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
494 acl_free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
495 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
496 # if HAVE_ACL_FREE_TEXT /* Tru64 */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
497 /* 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
498 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
499 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
500 # else /* FreeBSD, IRIX */
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
501 /* 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
502 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
503 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
504 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
505 call if the first one already failed. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
506 if (ret == 0 && S_ISDIR (sb->st_mode))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
507 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
508 acl = acl_get_file (name, ACL_TYPE_DEFAULT);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
509 if (acl)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
510 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
511 ret = (0 < acl_entries (acl));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
512 acl_free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
513 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
514 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
515 ret = -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
516 }
10173
33543159ba5b Don't test the ACL_TYPE_DEFAULT ACL on OSF/1.
Bruno Haible <bruno@clisp.org>
parents: 10172
diff changeset
517 # endif
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
518 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
519 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
520 ret = -1;
10172
50e666f281ef Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10158
diff changeset
521 # endif
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
522 }
8476
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
523 if (ret < 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
524 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
525 return ret;
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
526
13757
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
527 # 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
528
10191
ccfd3047da72 Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents: 10185
diff changeset
529 # 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
530
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
531 /* 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
532 <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
533 acl_fromtext, ...). */
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
534 return acl_trivial (name);
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
535
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
536 # else /* Solaris, Cygwin, general case */
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
537
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
538 /* 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
539 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
540 at once. */
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
541 int count;
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
542 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
543 aclent_t *entries;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
544
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
545 for (;;)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
546 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
547 count = acl (name, GETACLCNT, 0, NULL);
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
548
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
549 if (count < 0)
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 if (errno == ENOSYS || errno == ENOTSUP)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
552 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
553 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
554 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
555 }
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
556
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
557 if (count == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
558 break;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
559
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
560 /* 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
561 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
562 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
563 "user::", "group::", "other:", and "mask:" entries. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
564 if (count > 4)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
565 return 1;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
566
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
567 entries = (aclent_t *) malloc (count * sizeof (aclent_t));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
568 if (entries == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
569 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
570 errno = ENOMEM;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
571 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
572 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
573 if (acl (name, GETACL, count, entries) == count)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
574 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
575 if (acl_nontrivial (count, entries))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
576 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
577 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
578 return 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
579 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
580 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
581 break;
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 /* 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
584 Repeat. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
585 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
586 }
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
587 }
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
588
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
589 # ifdef ACE_GETACL
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
590 /* 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
591 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
592 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
593 ace_t *entries;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
594
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
595 for (;;)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
596 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
597 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
598
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
599 if (count < 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
600 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
601 if (errno == ENOSYS || errno == EINVAL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
602 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
603 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
604 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
605 }
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
606
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
607 if (count == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
608 break;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
609
15571
5d1d1c0b8204 acl: Fix a bug with NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents: 15570
diff changeset
610 /* 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
611 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
612 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
613 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
614 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
615 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
616 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
617 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
618 if (count > 6)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
619 return 1;
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
620
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
621 entries = (ace_t *) malloc (count * sizeof (ace_t));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
622 if (entries == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
623 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
624 errno = ENOMEM;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
625 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
626 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
627 if (acl (name, ACE_GETACL, count, entries) == count)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
628 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
629 if (acl_ace_nontrivial (count, entries))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
630 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
631 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
632 return 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
633 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
634 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
635 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
636 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
637 /* 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
638 Repeat. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
639 free (entries);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
640 }
10179
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
641 }
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
642 # endif
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
643
90f51b86b088 Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10177
diff changeset
644 return 0;
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
645 # endif
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
646
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
647 # elif HAVE_GETACL /* HP-UX */
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
648
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
649 for (;;)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
650 {
14905
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
651 int count;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
652 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
653
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
654 count = getacl (name, 0, NULL);
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
655
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
656 if (count < 0)
14904
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
657 {
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
658 /* 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
659 EOPNOTSUPP is typically seen on NFS mounts.
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
660 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
661 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
662 break;
14904
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
663 else
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
664 return -1;
812be65b0e8b acl: Complete the 2010-08-10 fix.
Bruno Haible <bruno@clisp.org>
parents: 14079
diff changeset
665 }
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
666
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
667 if (count == 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
668 return 0;
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
669
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
670 if (count > NACLENTRIES)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
671 /* If NACLENTRIES cannot be trusted, use dynamic memory
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
672 allocation. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
673 abort ();
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
674
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
675 /* 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
676 (uid,%), (%,gid), (%,%) entries. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
677 if (count > 3)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
678 return 1;
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
679
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
680 if (getacl (name, count, entries) == count)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
681 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
682 struct stat statbuf;
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
683
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
684 if (stat (name, &statbuf) < 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
685 return -1;
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
686
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
687 return acl_nontrivial (count, entries, &statbuf);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
688 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
689 /* 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
690 Repeat. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
691 }
10182
4a177f4b083f Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10179
diff changeset
692
14905
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
693 # 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
694
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
695 for (;;)
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
696 {
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
697 int count;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
698 struct acl entries[NACLVENTRIES];
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
699
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
700 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
701
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
702 if (count < 0)
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
703 {
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
704 /* 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
705 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
706 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
707 break;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
708 else
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
709 return -1;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
710 }
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
711
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
712 if (count == 0)
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
713 return 0;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
714
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
715 if (count > NACLVENTRIES)
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
716 /* 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
717 allocation. */
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
718 abort ();
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
719
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
720 /* 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
721 four base ACL entries. */
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
722 if (count > 4)
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
723 return 1;
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
724
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
725 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
726 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
727 /* 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
728 Repeat. */
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
729 }
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
730
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
731 # endif
a9b67d6b93df acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents: 14904
diff changeset
732
12077
72b0c1288a50 Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents: 12075
diff changeset
733 # 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
734
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
735 acl_type_t type;
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
736 char aclbuf[1024];
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
737 void *acl = aclbuf;
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
738 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
739 mode_t mode;
10183
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
740
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
741 for (;;)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
742 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
743 /* 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
744 is not true, in AIX 5.3. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
745 type.u64 = ACL_ANY;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
746 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
747 break;
15577
15d6c13d7aae acl: Update for AIX >= 5.3 with NFS.
Bruno Haible <bruno@clisp.org>
parents: 15573
diff changeset
748 if (errno == ENOSYS)
15d6c13d7aae acl: Update for AIX >= 5.3 with NFS.
Bruno Haible <bruno@clisp.org>
parents: 15573
diff changeset
749 return 0;
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
750 if (errno != ENOSPC)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
751 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
752 if (acl != aclbuf)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
753 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
754 int saved_errno = errno;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
755 free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
756 errno = saved_errno;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
757 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
758 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
759 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
760 aclsize = 2 * aclsize;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
761 if (acl != aclbuf)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
762 free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
763 acl = malloc (aclsize);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
764 if (acl == NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
765 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
766 errno = ENOMEM;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
767 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
768 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
769 }
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
770
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
771 if (type.u64 == ACL_AIXC)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
772 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
773 int result = acl_nontrivial ((struct acl *) acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
774 if (acl != aclbuf)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
775 free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
776 return result;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
777 }
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
778 else if (type.u64 == ACL_NFS4)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
779 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
780 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
781 if (acl != aclbuf)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
782 free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
783 return result;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
784 }
12075
c57301f2214b Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents: 11546
diff changeset
785 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
786 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
787 /* 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
788 We should better support it. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
789 if (acl != aclbuf)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
790 free (acl);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
791 errno = EINVAL;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
792 return -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 12146
diff changeset
793 }
10183
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
794
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
795 # elif HAVE_STATACL /* older AIX */
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
796
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
797 union { struct acl a; char room[4096]; } u;
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
798
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
799 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
800 return -1;
10183
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
801
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
802 return acl_nontrivial (&u.a);
e8efce9962b0 Add support for AIX ACLs.
Bruno Haible <bruno@clisp.org>
parents: 10182
diff changeset
803
13757
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
804 # elif HAVE_ACLSORT /* NonStop Kernel */
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
805
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
806 int count;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
807 struct acl entries[NACLENTRIES];
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
808
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
809 for (;;)
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
810 {
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
811 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
812
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
813 if (count < 0)
15573
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
814 {
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
815 if (errno == ENOSYS || errno == ENOTSUP)
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
816 break;
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
817 else
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
818 return -1;
132ec6dff66c acl: Avoid errors on NonStop Kernel.
Joachim Schmitz <schmitz@hp.com>
parents: 15572
diff changeset
819 }
13757
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
820
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
821 if (count == 0)
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
822 return 0;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
823
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
824 if (count > NACLENTRIES)
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
825 /* 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
826 allocation. */
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
827 abort ();
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
828
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
829 /* 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
830 four base ACL entries. */
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
831 if (count > 4)
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
832 return 1;
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
833
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
834 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
835 return acl_nontrivial (count, entries);
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
836 /* 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
837 Repeat. */
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
838 }
87aaf9340686 acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
839
10155
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
840 # endif
3df501903792 Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents: 10114
diff changeset
841 }
8476
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
842 #endif
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
843
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
844 return 0;
2798cb65bd90 Add limited support for Solaris 10 ZFS-style ACLs: just enough to
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
845 }