Mercurial > hg > octave-kai > gnulib-hg
annotate lib/set-mode-acl.c @ 16381:fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
* lib/file-has-acl.c (file_has_acl) [Solaris]: Treat a failing
acl()/facl() call for ACE_GETACL like a failing call for ACE_GETACLCNT.
* lib/set-mode-acl.c (qset_acl) [Solaris]: Likewise.
* lib/copy-acl.c (qcopy_acl)[Solaris]: Likewise.
* tests/test-sameacls.c (main)[Solaris]: Likewise.
Reported by Bill Jones in
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10639>, via Paul Eggert.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 19 Feb 2012 22:17:05 +0100 |
parents | ee1df2d14b96 |
children | cc05dad27529 |
rev | line source |
---|---|
10126 | 1 /* set-mode-acl.c - set access control list equivalent to a mode |
2 | |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15593
diff
changeset
|
3 Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc. |
10126 | 4 |
5 This program is free software: you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 3 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
10184 | 18 Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */ |
10126 | 19 |
20 #include <config.h> | |
21 | |
22 #include "acl.h" | |
23 | |
24 #include "acl-internal.h" | |
25 | |
10198
5056e8a13405
Include gettext.h only in those files that need it.
Bruno Haible <bruno@clisp.org>
parents:
10191
diff
changeset
|
26 #include "gettext.h" |
5056e8a13405
Include gettext.h only in those files that need it.
Bruno Haible <bruno@clisp.org>
parents:
10191
diff
changeset
|
27 #define _(msgid) gettext (msgid) |
5056e8a13405
Include gettext.h only in those files that need it.
Bruno Haible <bruno@clisp.org>
parents:
10191
diff
changeset
|
28 |
5056e8a13405
Include gettext.h only in those files that need it.
Bruno Haible <bruno@clisp.org>
parents:
10191
diff
changeset
|
29 |
10126 | 30 /* If DESC is a valid file descriptor use fchmod to change the |
31 file's mode to MODE on systems that have fchown. On systems | |
32 that don't have fchown and if DESC is invalid, use chown on | |
10169
7215efd0ff4f
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10168
diff
changeset
|
33 NAME instead. |
7215efd0ff4f
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10168
diff
changeset
|
34 Return 0 if successful. Return -1 and set errno upon failure. */ |
10126 | 35 |
36 int | |
37 chmod_or_fchmod (const char *name, int desc, mode_t mode) | |
38 { | |
39 if (HAVE_FCHMOD && desc != -1) | |
40 return fchmod (desc, mode); | |
41 else | |
42 return chmod (name, mode); | |
43 } | |
44 | |
45 /* Set the access control lists of a file. If DESC is a valid file | |
46 descriptor, use file descriptor operations where available, else use | |
47 filename based operations on NAME. If access control lists are not | |
48 available, fchmod the target file to MODE. Also sets the | |
49 non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX) | |
10150
0c9f7838132c
Document qset_acl return value precisely.
Bruno Haible <bruno@clisp.org>
parents:
10126
diff
changeset
|
50 to those from MODE if any are set. |
0c9f7838132c
Document qset_acl return value precisely.
Bruno Haible <bruno@clisp.org>
parents:
10126
diff
changeset
|
51 Return 0 if successful. Return -1 and set errno upon failure. */ |
10126 | 52 |
53 int | |
54 qset_acl (char const *name, int desc, mode_t mode) | |
55 { | |
56 #if USE_ACL | |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
57 # if HAVE_ACL_GET_FILE |
10126 | 58 /* POSIX 1003.1e draft 17 (abandoned) specific version. */ |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
59 /* Linux, FreeBSD, MacOS X, IRIX, Tru64 */ |
15575
3e19c8849877
acl: Fix a test failure on IRIX 6.5 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15572
diff
changeset
|
60 # if !HAVE_ACL_TYPE_EXTENDED |
10126 | 61 /* Linux, FreeBSD, IRIX, Tru64 */ |
62 | |
63 /* We must also have acl_from_text and acl_delete_def_file. | |
64 (acl_delete_def_file could be emulated with acl_init followed | |
65 by acl_set_file, but acl_set_file with an empty acl is | |
66 unspecified.) */ | |
67 | |
68 # ifndef HAVE_ACL_FROM_TEXT | |
69 # error Must have acl_from_text (see POSIX 1003.1e draft 17). | |
70 # endif | |
71 # ifndef HAVE_ACL_DELETE_DEF_FILE | |
72 # error Must have acl_delete_def_file (see POSIX 1003.1e draft 17). | |
73 # endif | |
74 | |
75 acl_t acl; | |
76 int ret; | |
77 | |
78 if (HAVE_ACL_FROM_MODE) /* Linux */ | |
79 { | |
80 acl = acl_from_mode (mode); | |
81 if (!acl) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
82 return -1; |
10126 | 83 } |
84 else /* FreeBSD, IRIX, Tru64 */ | |
85 { | |
86 /* If we were to create the ACL using the functions acl_init(), | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
87 acl_create_entry(), acl_set_tag_type(), acl_set_qualifier(), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
88 acl_get_permset(), acl_clear_perm[s](), acl_add_perm(), we |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
89 would need to create a qualifier. I don't know how to do this. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
90 So create it using acl_from_text(). */ |
10126 | 91 |
92 # if HAVE_ACL_FREE_TEXT /* Tru64 */ | |
93 char acl_text[] = "u::---,g::---,o::---,"; | |
94 # else /* FreeBSD, IRIX */ | |
95 char acl_text[] = "u::---,g::---,o::---"; | |
96 # endif | |
97 | |
98 if (mode & S_IRUSR) acl_text[ 3] = 'r'; | |
99 if (mode & S_IWUSR) acl_text[ 4] = 'w'; | |
100 if (mode & S_IXUSR) acl_text[ 5] = 'x'; | |
101 if (mode & S_IRGRP) acl_text[10] = 'r'; | |
102 if (mode & S_IWGRP) acl_text[11] = 'w'; | |
103 if (mode & S_IXGRP) acl_text[12] = 'x'; | |
104 if (mode & S_IROTH) acl_text[17] = 'r'; | |
105 if (mode & S_IWOTH) acl_text[18] = 'w'; | |
106 if (mode & S_IXOTH) acl_text[19] = 'x'; | |
107 | |
108 acl = acl_from_text (acl_text); | |
109 if (!acl) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
110 return -1; |
10126 | 111 } |
112 if (HAVE_ACL_SET_FD && desc != -1) | |
113 ret = acl_set_fd (desc, acl); | |
114 else | |
115 ret = acl_set_file (name, ACL_TYPE_ACCESS, acl); | |
116 if (ret != 0) | |
117 { | |
118 int saved_errno = errno; | |
119 acl_free (acl); | |
120 | |
121 if (ACL_NOT_WELL_SUPPORTED (errno)) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
122 return chmod_or_fchmod (name, desc, mode); |
10176
43bafd6ea0d8
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
123 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
124 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
125 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
126 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
127 } |
10126 | 128 } |
129 else | |
130 acl_free (acl); | |
131 | |
132 if (S_ISDIR (mode) && acl_delete_def_file (name)) | |
133 return -1; | |
134 | |
15575
3e19c8849877
acl: Fix a test failure on IRIX 6.5 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15572
diff
changeset
|
135 if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX))) |
10126 | 136 { |
15575
3e19c8849877
acl: Fix a test failure on IRIX 6.5 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15572
diff
changeset
|
137 /* We did not call chmod so far, and either the mode and the ACL are |
3e19c8849877
acl: Fix a test failure on IRIX 6.5 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15572
diff
changeset
|
138 separate or special bits are to be set which don't fit into ACLs. */ |
10176
43bafd6ea0d8
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
139 return chmod_or_fchmod (name, desc, mode); |
10126 | 140 } |
141 return 0; | |
142 | |
15575
3e19c8849877
acl: Fix a test failure on IRIX 6.5 with NFS.
Bruno Haible <bruno@clisp.org>
parents:
15572
diff
changeset
|
143 # else /* HAVE_ACL_TYPE_EXTENDED */ |
10126 | 144 /* MacOS X */ |
145 | |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
146 /* On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
147 and acl_get_file (name, ACL_TYPE_DEFAULT) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
148 always return NULL / EINVAL. You have to use |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
149 acl_get_file (name, ACL_TYPE_EXTENDED) |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
150 or acl_get_fd (open (name, ...)) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
151 to retrieve an ACL. |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
152 On the other hand, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
153 acl_set_file (name, ACL_TYPE_ACCESS, acl) |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
154 and acl_set_file (name, ACL_TYPE_DEFAULT, acl) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
155 have the same effect as |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
156 acl_set_file (name, ACL_TYPE_EXTENDED, acl): |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
157 Each of these calls sets the file's ACL. */ |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
158 |
10126 | 159 acl_t acl; |
160 int ret; | |
161 | |
162 /* Remove the ACL if the file has ACLs. */ | |
163 if (HAVE_ACL_GET_FD && desc != -1) | |
164 acl = acl_get_fd (desc); | |
165 else | |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
166 acl = acl_get_file (name, ACL_TYPE_EXTENDED); |
10126 | 167 if (acl) |
168 { | |
10171
f988df7e273d
Fix memory leak introduced on 2008-05-22.
Bruno Haible <bruno@clisp.org>
parents:
10170
diff
changeset
|
169 acl_free (acl); |
f988df7e273d
Fix memory leak introduced on 2008-05-22.
Bruno Haible <bruno@clisp.org>
parents:
10170
diff
changeset
|
170 |
10170
75a6b6b966a8
Avoid needing to know the textual representation of an ACL when possible.
Bruno Haible <bruno@clisp.org>
parents:
10169
diff
changeset
|
171 acl = acl_init (0); |
10126 | 172 if (acl) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
173 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
174 if (HAVE_ACL_SET_FD && desc != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
175 ret = acl_set_fd (desc, acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
176 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
177 ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
178 if (ret != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
179 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
180 int saved_errno = errno; |
10126 | 181 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
182 acl_free (acl); |
10126 | 183 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
184 if (ACL_NOT_WELL_SUPPORTED (saved_errno)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
185 return chmod_or_fchmod (name, desc, mode); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
186 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
187 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
188 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
189 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
190 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
191 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
192 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
193 } |
10126 | 194 } |
195 | |
10176
43bafd6ea0d8
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
196 /* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */ |
10126 | 197 return chmod_or_fchmod (name, desc, mode); |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
198 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
199 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
200 # elif HAVE_FACL && defined GETACLCNT /* Solaris, Cygwin, not HP-UX */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
201 |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
202 int done_setacl = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
203 |
15572
dd7c06a51643
acl: Clean up Solaris code.
Bruno Haible <bruno@clisp.org>
parents:
15567
diff
changeset
|
204 # ifdef ACE_GETACL |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
205 /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
206 file systems (whereas the other ones are used in UFS file systems). */ |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
207 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
208 /* 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:
10184
diff
changeset
|
209 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:
10184
diff
changeset
|
210 How to distinguish the two conventions at runtime? |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
211 We fetch the existing ACL. In the old convention, usually three ACEs have |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
212 a_flags = ACE_OWNER / ACE_GROUP / ACE_OTHER, in the range 0x0100..0x0400. |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
213 In the new convention, these values are not used. */ |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
214 int convention; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
215 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
216 { |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
217 int count; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
218 ace_t *entries; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
219 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
220 for (;;) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
221 { |
16381
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
222 int ret; |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
223 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
224 if (desc != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
225 count = facl (desc, ACE_GETACLCNT, 0, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
226 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
227 count = acl (name, ACE_GETACLCNT, 0, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
228 if (count <= 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
229 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
230 convention = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
231 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
232 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
233 entries = (ace_t *) malloc (count * sizeof (ace_t)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
234 if (entries == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
235 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
236 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
237 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
238 } |
16381
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
239 ret = (desc != -1 |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
240 ? facl (desc, ACE_GETACL, count, entries) |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
241 : acl (name, ACE_GETACL, count, entries)); |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
242 if (ret < 0) |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
243 { |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
244 free (entries); |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
245 convention = -1; |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
246 break; |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
247 } |
fc5c37ccbece
acl: Fix endless loop on Solaris with vxfs.
Bruno Haible <bruno@clisp.org>
parents:
16269
diff
changeset
|
248 if (ret == count) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
249 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
250 int i; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
251 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
252 convention = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
253 for (i = 0; i < count; i++) |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
254 if (entries[i].a_flags & (OLD_ACE_OWNER | OLD_ACE_GROUP | OLD_ACE_OTHER)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
255 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
256 convention = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
257 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
258 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
259 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
260 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
261 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
262 /* Huh? The number of ACL entries changed since the last call. |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
263 Repeat. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
264 free (entries); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
265 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
266 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
267 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
268 if (convention >= 0) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
269 { |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
270 ace_t entries[6]; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
271 int count; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
272 int ret; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
273 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
274 if (convention) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
275 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
276 /* Running on Solaris 10. */ |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
277 entries[0].a_type = OLD_ALLOW; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
278 entries[0].a_flags = OLD_ACE_OWNER; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
279 entries[0].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
280 entries[0].a_access_mask = (mode >> 6) & 7; |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
281 entries[1].a_type = OLD_ALLOW; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
282 entries[1].a_flags = OLD_ACE_GROUP; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
283 entries[1].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
284 entries[1].a_access_mask = (mode >> 3) & 7; |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
285 entries[2].a_type = OLD_ALLOW; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
286 entries[2].a_flags = OLD_ACE_OTHER; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
287 entries[2].a_who = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
288 entries[2].a_access_mask = mode & 7; |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
289 count = 3; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
290 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
291 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
292 { |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
293 /* Running on Solaris 10 (newer version) or Solaris 11. |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
294 The details here were found through "/bin/ls -lvd somefiles". */ |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
295 entries[0].a_type = NEW_ACE_ACCESS_DENIED_ACE_TYPE; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
296 entries[0].a_flags = NEW_ACE_OWNER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
297 entries[0].a_who = 0; /* irrelevant */ |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
298 entries[0].a_access_mask = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
299 entries[1].a_type = NEW_ACE_ACCESS_ALLOWED_ACE_TYPE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
300 entries[1].a_flags = NEW_ACE_OWNER; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
301 entries[1].a_who = 0; /* irrelevant */ |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
302 entries[1].a_access_mask = NEW_ACE_WRITE_NAMED_ATTRS |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
303 | NEW_ACE_WRITE_ATTRIBUTES |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
304 | NEW_ACE_WRITE_ACL |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
305 | NEW_ACE_WRITE_OWNER; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
306 if (mode & 0400) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
307 entries[1].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
308 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
309 entries[0].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
310 if (mode & 0200) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
311 entries[1].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
312 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
313 entries[0].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
314 if (mode & 0100) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
315 entries[1].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
316 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
317 entries[0].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
318 entries[2].a_type = NEW_ACE_ACCESS_DENIED_ACE_TYPE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
319 entries[2].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
320 entries[2].a_who = 0; /* irrelevant */ |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
321 entries[2].a_access_mask = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
322 entries[3].a_type = NEW_ACE_ACCESS_ALLOWED_ACE_TYPE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
323 entries[3].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
324 entries[3].a_who = 0; /* irrelevant */ |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
325 entries[3].a_access_mask = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
326 if (mode & 0040) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
327 entries[3].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
328 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
329 entries[2].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
330 if (mode & 0020) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
331 entries[3].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
332 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
333 entries[2].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
334 if (mode & 0010) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
335 entries[3].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
336 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
337 entries[2].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
338 entries[4].a_type = NEW_ACE_ACCESS_DENIED_ACE_TYPE; |
15593
270852a80105
acl: Fix compilation on Solaris 10 (older version).
Bruno Haible <bruno@clisp.org>
parents:
15575
diff
changeset
|
339 entries[4].a_flags = NEW_ACE_EVERYONE; |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
340 entries[4].a_who = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
341 entries[4].a_access_mask = NEW_ACE_WRITE_NAMED_ATTRS |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
342 | NEW_ACE_WRITE_ATTRIBUTES |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
343 | NEW_ACE_WRITE_ACL |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
344 | NEW_ACE_WRITE_OWNER; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
345 entries[5].a_type = NEW_ACE_ACCESS_ALLOWED_ACE_TYPE; |
15593
270852a80105
acl: Fix compilation on Solaris 10 (older version).
Bruno Haible <bruno@clisp.org>
parents:
15575
diff
changeset
|
346 entries[5].a_flags = NEW_ACE_EVERYONE; |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
347 entries[5].a_who = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
348 entries[5].a_access_mask = NEW_ACE_READ_NAMED_ATTRS |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
349 | NEW_ACE_READ_ATTRIBUTES |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
350 | NEW_ACE_READ_ACL |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
351 | NEW_ACE_SYNCHRONIZE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
352 if (mode & 0004) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
353 entries[5].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
354 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
355 entries[4].a_access_mask |= NEW_ACE_READ_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
356 if (mode & 0002) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
357 entries[5].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
358 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
359 entries[4].a_access_mask |= NEW_ACE_WRITE_DATA | NEW_ACE_APPEND_DATA; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
360 if (mode & 0001) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
361 entries[5].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
362 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
363 entries[4].a_access_mask |= NEW_ACE_EXECUTE; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
364 count = 6; |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
365 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
366 if (desc != -1) |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
367 ret = facl (desc, ACE_SETACL, count, entries); |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
368 else |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
369 ret = acl (name, ACE_SETACL, count, entries); |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
370 if (ret < 0 && errno != EINVAL && errno != ENOTSUP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
371 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
372 if (errno == ENOSYS) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
373 return chmod_or_fchmod (name, desc, mode); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
374 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
375 } |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
376 if (ret == 0) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
377 done_setacl = 1; |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
378 } |
15572
dd7c06a51643
acl: Clean up Solaris code.
Bruno Haible <bruno@clisp.org>
parents:
15567
diff
changeset
|
379 # endif |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
380 |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
381 if (!done_setacl) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
382 { |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
383 aclent_t entries[3]; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
384 int ret; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
385 |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
386 entries[0].a_type = USER_OBJ; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
387 entries[0].a_id = 0; /* irrelevant */ |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
388 entries[0].a_perm = (mode >> 6) & 7; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
389 entries[1].a_type = GROUP_OBJ; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
390 entries[1].a_id = 0; /* irrelevant */ |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
391 entries[1].a_perm = (mode >> 3) & 7; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
392 entries[2].a_type = OTHER_OBJ; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
393 entries[2].a_id = 0; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
394 entries[2].a_perm = mode & 7; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
395 |
15566
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
396 if (desc != -1) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
397 ret = facl (desc, SETACL, |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
398 sizeof (entries) / sizeof (aclent_t), entries); |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
399 else |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
400 ret = acl (name, SETACL, |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
401 sizeof (entries) / sizeof (aclent_t), entries); |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
402 if (ret < 0) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
403 { |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
404 if (errno == ENOSYS || errno == EOPNOTSUPP) |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
405 return chmod_or_fchmod (name, desc, mode); |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
406 return -1; |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
407 } |
8339ac6126c5
acl: Improve support of NFSv4 ACLs on Solaris 10 (newer version).
Bruno Haible <bruno@clisp.org>
parents:
14905
diff
changeset
|
408 } |
10184 | 409 |
10181
5282ccc922b9
Add support for Cygwin ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10180
diff
changeset
|
410 if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX))) |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
411 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
412 /* We did not call chmod so far, so the special bits have not yet |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
413 been set. */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
414 return chmod_or_fchmod (name, desc, mode); |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
415 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
416 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
417 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
418 # elif HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
419 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
420 struct stat statbuf; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
421 int ret; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
422 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
423 if (desc != -1) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
424 ret = fstat (desc, &statbuf); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
425 else |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
426 ret = stat (name, &statbuf); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
427 if (ret < 0) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
428 return -1; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
429 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
430 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
431 struct acl_entry entries[3]; |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
432 |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
433 entries[0].uid = statbuf.st_uid; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
434 entries[0].gid = ACL_NSGROUP; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
435 entries[0].mode = (mode >> 6) & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
436 entries[1].uid = ACL_NSUSER; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
437 entries[1].gid = statbuf.st_gid; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
438 entries[1].mode = (mode >> 3) & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
439 entries[2].uid = ACL_NSUSER; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
440 entries[2].gid = ACL_NSGROUP; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
441 entries[2].mode = mode & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
442 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
443 if (desc != -1) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
444 ret = fsetacl (desc, sizeof (entries) / sizeof (struct acl_entry), entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
445 else |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
446 ret = setacl (name, sizeof (entries) / sizeof (struct acl_entry), entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
447 } |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
448 if (ret < 0) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
449 { |
14905
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
450 if (!(errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
451 return -1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
452 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
453 # 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
|
454 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
455 struct acl entries[4]; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
456 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
457 entries[0].a_type = USER_OBJ; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
458 entries[0].a_id = 0; /* irrelevant */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
459 entries[0].a_perm = (mode >> 6) & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
460 entries[1].a_type = GROUP_OBJ; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
461 entries[1].a_id = 0; /* irrelevant */ |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
462 entries[1].a_perm = (mode >> 3) & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
463 entries[2].a_type = CLASS_OBJ; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
464 entries[2].a_id = 0; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
465 entries[2].a_perm = (mode >> 3) & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
466 entries[3].a_type = OTHER_OBJ; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
467 entries[3].a_id = 0; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
468 entries[3].a_perm = mode & 7; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
469 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
470 ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
471 if (ret > 0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
472 abort (); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
473 if (ret < 0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
474 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
475 if (0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
476 return chmod_or_fchmod (name, desc, mode); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
477 return -1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
478 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
479 |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
480 ret = acl ((char *) name, ACL_SET, |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
481 sizeof (entries) / sizeof (struct acl), entries); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
482 if (ret < 0) |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
483 { |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
484 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
|
485 return chmod_or_fchmod (name, desc, mode); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
486 return -1; |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
487 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
488 } |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
489 # else |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
490 return chmod_or_fchmod (name, desc, mode); |
a9b67d6b93df
acl: Add support for HP-UX >= 11.11 JFS ACLs.
Bruno Haible <bruno@clisp.org>
parents:
14904
diff
changeset
|
491 # endif |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
492 } |
10184 | 493 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
494 if (mode & (S_ISUID | S_ISGID | S_ISVTX)) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
495 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
496 /* We did not call chmod so far, so the special bits have not yet |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
497 been set. */ |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
498 return chmod_or_fchmod (name, desc, mode); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
499 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
500 return 0; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
501 |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
502 # 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:
11917
diff
changeset
|
503 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
504 acl_type_list_t types; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
505 size_t types_size = sizeof (types); |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
506 acl_type_t type; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
507 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
508 if (aclx_gettypes (name, &types, &types_size) < 0 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
509 || types.num_entries == 0) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
510 return chmod_or_fchmod (name, desc, mode); |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
511 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
512 /* XXX Do we need to clear all types of ACLs for the given file, or is it |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
513 sufficient to clear the first one? */ |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
514 type = types.entries[0]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
515 if (type.u64 == ACL_AIXC) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
516 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
517 union { struct acl a; char room[128]; } u; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
518 int ret; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
519 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
520 u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */ |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
521 u.a.acl_mode = mode & ~(S_IXACL | 0777); |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
522 u.a.u_access = (mode >> 6) & 7; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
523 u.a.g_access = (mode >> 3) & 7; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
524 u.a.o_access = mode & 7; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
525 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
526 if (desc != -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
527 ret = aclx_fput (desc, SET_ACL | SET_MODE_S_BITS, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
528 type, &u.a, u.a.acl_len, mode); |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
529 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
530 ret = aclx_put (name, SET_ACL | SET_MODE_S_BITS, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
531 type, &u.a, u.a.acl_len, mode); |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
532 if (!(ret < 0 && errno == ENOSYS)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
533 return ret; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
534 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
535 else if (type.u64 == ACL_NFS4) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
536 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
537 union { nfs4_acl_int_t a; char room[128]; } u; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
538 nfs4_ace_int_t *ace; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
539 int ret; |
10183 | 540 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
541 u.a.aclVersion = NFS4_ACL_INT_STRUCT_VERSION; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
542 u.a.aclEntryN = 0; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
543 ace = &u.a.aclEntry[0]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
544 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
545 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
546 ace->aceWho.special_whoid = ACE4_WHO_OWNER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
547 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
548 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
549 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
550 (mode & 0400 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
551 | (mode & 0200 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
552 ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
553 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
554 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
555 | (mode & 0100 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
556 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
557 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
558 ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
559 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
560 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
561 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
562 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
563 ace->aceWho.special_whoid = ACE4_WHO_GROUP; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
564 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
565 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
566 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
567 (mode & 0040 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
568 | (mode & 0020 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
569 ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
570 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
571 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
572 | (mode & 0010 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
573 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
574 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
575 ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
576 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
577 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
578 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
579 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
580 ace->aceWho.special_whoid = ACE4_WHO_EVERYONE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
581 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
582 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
583 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
584 (mode & 0004 ? ACE4_READ_DATA | ACE4_LIST_DIRECTORY : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
585 | (mode & 0002 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
586 ? ACE4_WRITE_DATA | ACE4_ADD_FILE | ACE4_APPEND_DATA |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
587 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
588 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
589 | (mode & 0001 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
590 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
591 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
592 ace = (nfs4_ace_int_t *) (char *) &ace->aceWhoString[4]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
593 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
594 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
595 u.a.aclLength = (char *) ace - (char *) &u.a; |
10183 | 596 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
597 if (desc != -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
598 ret = aclx_fput (desc, SET_ACL | SET_MODE_S_BITS, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
599 type, &u.a, u.a.aclLength, mode); |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
600 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
601 ret = aclx_put (name, SET_ACL | SET_MODE_S_BITS, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
602 type, &u.a, u.a.aclLength, mode); |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
603 if (!(ret < 0 && errno == ENOSYS)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
604 return ret; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
605 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
606 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
607 return chmod_or_fchmod (name, desc, mode); |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
608 |
10183 | 609 # elif HAVE_STATACL /* older AIX */ |
610 | |
611 union { struct acl a; char room[128]; } u; | |
612 int ret; | |
613 | |
614 u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */ | |
615 u.a.acl_mode = mode & ~(S_IXACL | 0777); | |
616 u.a.u_access = (mode >> 6) & 7; | |
617 u.a.g_access = (mode >> 3) & 7; | |
618 u.a.o_access = mode & 7; | |
619 | |
620 if (desc != -1) | |
621 ret = fchacl (desc, &u.a, u.a.acl_len); | |
622 else | |
623 ret = chacl (name, &u.a, u.a.acl_len); | |
624 | |
625 if (ret < 0 && errno == ENOSYS) | |
626 return chmod_or_fchmod (name, desc, mode); | |
627 | |
628 return ret; | |
629 | |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
630 # elif HAVE_ACLSORT /* NonStop Kernel */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
631 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
632 struct acl entries[4]; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
633 int ret; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
634 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
635 entries[0].a_type = USER_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
636 entries[0].a_id = 0; /* irrelevant */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
637 entries[0].a_perm = (mode >> 6) & 7; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
638 entries[1].a_type = GROUP_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
639 entries[1].a_id = 0; /* irrelevant */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
640 entries[1].a_perm = (mode >> 3) & 7; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
641 entries[2].a_type = CLASS_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
642 entries[2].a_id = 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
643 entries[2].a_perm = (mode >> 3) & 7; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
644 entries[3].a_type = OTHER_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
645 entries[3].a_id = 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
646 entries[3].a_perm = mode & 7; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
647 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
648 ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
649 if (ret > 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
650 abort (); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
651 if (ret < 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
652 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
653 if (0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
654 return chmod_or_fchmod (name, desc, mode); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
655 return -1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
656 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
657 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
658 ret = acl ((char *) name, ACL_SET, |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
659 sizeof (entries) / sizeof (struct acl), entries); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
660 if (ret < 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
661 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
662 if (0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
663 return chmod_or_fchmod (name, desc, mode); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
664 return -1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
665 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
666 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
667 if (mode & (S_ISUID | S_ISGID | S_ISVTX)) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
668 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
669 /* We did not call chmod so far, so the special bits have not yet |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
670 been set. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
671 return chmod_or_fchmod (name, desc, mode); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
672 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
673 return 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
674 |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
675 # else /* Unknown flavor of ACLs */ |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
676 return chmod_or_fchmod (name, desc, mode); |
10126 | 677 # endif |
678 #else /* !USE_ACL */ | |
679 return chmod_or_fchmod (name, desc, mode); | |
680 #endif | |
681 } | |
682 | |
683 /* As with qset_acl, but also output a diagnostic on failure. */ | |
684 | |
685 int | |
686 set_acl (char const *name, int desc, mode_t mode) | |
687 { | |
16269
ee1df2d14b96
acl: Rename a local variable.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
688 int ret = qset_acl (name, desc, mode); |
ee1df2d14b96
acl: Rename a local variable.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
689 if (ret != 0) |
10126 | 690 error (0, errno, _("setting permissions for %s"), quote (name)); |
16269
ee1df2d14b96
acl: Rename a local variable.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
691 return ret; |
10126 | 692 } |