Mercurial > hg > octave-kai > gnulib-hg
annotate lib/set-mode-acl.c @ 14079:97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Run the new "make update-copyright" rule.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sat, 01 Jan 2011 20:17:23 +0100 |
parents | 87aaf9340686 |
children | 812be65b0e8b |
rev | line source |
---|---|
10126 | 1 /* set-mode-acl.c - set access control list equivalent to a mode |
2 | |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13757
diff
changeset
|
3 Copyright (C) 2002-2003, 2005-2011 Free Software Foundation, Inc. |
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 */ |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
60 # if MODE_INSIDE_ACL |
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 | |
135 if (mode & (S_ISUID | S_ISGID | S_ISVTX)) | |
136 { | |
137 /* 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
|
138 been set. */ |
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 | |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
143 # else /* !MODE_INSIDE_ACL */ |
10126 | 144 /* MacOS X */ |
145 | |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
146 # if !HAVE_ACL_TYPE_EXTENDED |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
147 # error Must have ACL_TYPE_EXTENDED |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
148 # endif |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
149 |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
150 /* 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
|
151 and acl_get_file (name, ACL_TYPE_DEFAULT) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
152 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
|
153 acl_get_file (name, ACL_TYPE_EXTENDED) |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
154 or acl_get_fd (open (name, ...)) |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
155 to retrieve an ACL. |
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
156 On the other hand, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
157 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
|
158 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
|
159 have the same effect as |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
160 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
|
161 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
|
162 |
10126 | 163 acl_t acl; |
164 int ret; | |
165 | |
166 /* Remove the ACL if the file has ACLs. */ | |
167 if (HAVE_ACL_GET_FD && desc != -1) | |
168 acl = acl_get_fd (desc); | |
169 else | |
10172
50e666f281ef
Add support for MacOS X ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10171
diff
changeset
|
170 acl = acl_get_file (name, ACL_TYPE_EXTENDED); |
10126 | 171 if (acl) |
172 { | |
10171
f988df7e273d
Fix memory leak introduced on 2008-05-22.
Bruno Haible <bruno@clisp.org>
parents:
10170
diff
changeset
|
173 acl_free (acl); |
f988df7e273d
Fix memory leak introduced on 2008-05-22.
Bruno Haible <bruno@clisp.org>
parents:
10170
diff
changeset
|
174 |
10170
75a6b6b966a8
Avoid needing to know the textual representation of an ACL when possible.
Bruno Haible <bruno@clisp.org>
parents:
10169
diff
changeset
|
175 acl = acl_init (0); |
10126 | 176 if (acl) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
177 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
178 if (HAVE_ACL_SET_FD && desc != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
179 ret = acl_set_fd (desc, acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
180 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
181 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
|
182 if (ret != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
183 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
184 int saved_errno = errno; |
10126 | 185 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
186 acl_free (acl); |
10126 | 187 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
188 if (ACL_NOT_WELL_SUPPORTED (saved_errno)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
189 return chmod_or_fchmod (name, desc, mode); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
190 else |
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 errno = saved_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
193 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
194 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
195 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
196 acl_free (acl); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
197 } |
10126 | 198 } |
199 | |
10176
43bafd6ea0d8
Trivial code simplifications.
Bruno Haible <bruno@clisp.org>
parents:
10172
diff
changeset
|
200 /* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */ |
10126 | 201 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
|
202 # endif |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
203 |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
204 # 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
|
205 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
206 # if defined ACL_NO_TRIVIAL |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
207 /* Solaris 10 (newer version), which has additional API declared in |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
208 <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial, |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
209 acl_fromtext, ...). */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
210 |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
211 acl_t *aclp; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
212 char acl_text[] = "user::---,group::---,mask:---,other:---"; |
10180
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
213 int ret; |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
214 int saved_errno; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
215 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
216 if (mode & S_IRUSR) acl_text[ 6] = 'r'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
217 if (mode & S_IWUSR) acl_text[ 7] = 'w'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
218 if (mode & S_IXUSR) acl_text[ 8] = 'x'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
219 if (mode & S_IRGRP) acl_text[17] = acl_text[26] = 'r'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
220 if (mode & S_IWGRP) acl_text[18] = acl_text[27] = 'w'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
221 if (mode & S_IXGRP) acl_text[19] = acl_text[28] = 'x'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
222 if (mode & S_IROTH) acl_text[36] = 'r'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
223 if (mode & S_IWOTH) acl_text[37] = 'w'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
224 if (mode & S_IXOTH) acl_text[38] = 'x'; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
225 |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
226 if (acl_fromtext (acl_text, &aclp) != 0) |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
227 { |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
228 errno = ENOMEM; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
229 return -1; |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
230 } |
10180
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
231 |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
232 ret = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp)); |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
233 saved_errno = errno; |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
234 acl_free (aclp); |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
235 if (ret < 0) |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
236 { |
11917
afaea9930971
Fix an unnecessary error on Solaris 10 on NFSv3 file systems.
Bruno Haible <bruno@clisp.org>
parents:
11544
diff
changeset
|
237 if (saved_errno == ENOSYS || saved_errno == EOPNOTSUPP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
238 return chmod_or_fchmod (name, desc, mode); |
10180
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
239 errno = saved_errno; |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
240 return -1; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
241 } |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
242 |
10180
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
243 if (mode & (S_ISUID | S_ISGID | S_ISVTX)) |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
244 { |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
245 /* 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
|
246 been set. */ |
10180
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
247 return chmod_or_fchmod (name, desc, mode); |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
248 } |
9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
Bruno Haible <bruno@clisp.org>
parents:
10179
diff
changeset
|
249 return 0; |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
250 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
251 # else /* Solaris, Cygwin, general case */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
252 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
253 # ifdef ACE_GETACL |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
254 /* 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
|
255 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
|
256 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
257 /* 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 int convention; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
264 |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
265 { |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
266 int count; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
267 ace_t *entries; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
268 |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
269 for (;;) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
270 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
271 if (desc != -1) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
272 count = facl (desc, ACE_GETACLCNT, 0, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
273 else |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
274 count = acl (name, ACE_GETACLCNT, 0, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
275 if (count <= 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
276 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
277 convention = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
278 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
279 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
280 entries = (ace_t *) malloc (count * sizeof (ace_t)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
281 if (entries == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
282 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
283 errno = ENOMEM; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
284 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
285 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
286 if ((desc != -1 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
287 ? facl (desc, ACE_GETACL, count, entries) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
288 : acl (name, ACE_GETACL, count, entries)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
289 == count) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
290 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
291 int i; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
292 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
293 convention = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
294 for (i = 0; i < count; i++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
295 if (entries[i].a_flags & (ACE_OWNER | ACE_GROUP | ACE_OTHER)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
296 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
297 convention = 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
298 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
299 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
300 free (entries); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
301 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
302 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
303 /* 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
|
304 Repeat. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
305 free (entries); |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
306 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
307 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
308 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
309 if (convention >= 0) |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
310 { |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
311 ace_t entries[3]; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
312 int ret; |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
313 |
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
314 if (convention) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
315 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
316 /* Running on Solaris 10. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
317 entries[0].a_type = ALLOW; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
318 entries[0].a_flags = ACE_OWNER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
319 entries[0].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
320 entries[0].a_access_mask = (mode >> 6) & 7; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
321 entries[1].a_type = ALLOW; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
322 entries[1].a_flags = ACE_GROUP; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
323 entries[1].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
324 entries[1].a_access_mask = (mode >> 3) & 7; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
325 entries[2].a_type = ALLOW; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
326 entries[2].a_flags = ACE_OTHER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
327 entries[2].a_who = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
328 entries[2].a_access_mask = mode & 7; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
329 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
330 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
331 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
332 /* Running on Solaris 10 (newer version) or Solaris 11. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
333 entries[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
334 entries[0].a_flags = NEW_ACE_OWNER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
335 entries[0].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
336 entries[0].a_access_mask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
337 (mode & 0400 ? NEW_ACE_READ_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
338 | (mode & 0200 ? NEW_ACE_WRITE_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
339 | (mode & 0100 ? NEW_ACE_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
340 entries[1].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
341 entries[1].a_flags = NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
342 entries[1].a_who = 0; /* irrelevant */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
343 entries[1].a_access_mask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
344 (mode & 0040 ? NEW_ACE_READ_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
345 | (mode & 0020 ? NEW_ACE_WRITE_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
346 | (mode & 0010 ? NEW_ACE_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
347 entries[2].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
348 entries[2].a_flags = ACE_EVERYONE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
349 entries[2].a_who = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
350 entries[2].a_access_mask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
351 (mode & 0004 ? NEW_ACE_READ_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
352 | (mode & 0002 ? NEW_ACE_WRITE_DATA : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
353 | (mode & 0001 ? NEW_ACE_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
354 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
355 if (desc != -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
356 ret = facl (desc, ACE_SETACL, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
357 sizeof (entries) / sizeof (ace_t), entries); |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
358 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
359 ret = acl (name, ACE_SETACL, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
360 sizeof (entries) / sizeof (ace_t), entries); |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
361 if (ret < 0 && errno != EINVAL && errno != ENOTSUP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
362 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
363 if (errno == ENOSYS) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
364 return chmod_or_fchmod (name, desc, mode); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
365 return -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
366 } |
10191
ccfd3047da72
Work around the Solaris 10 ACE ACLs ABI change.
Bruno Haible <bruno@clisp.org>
parents:
10184
diff
changeset
|
367 } |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
368 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
369 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
370 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
371 aclent_t entries[3]; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
372 int ret; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
373 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
374 entries[0].a_type = USER_OBJ; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
375 entries[0].a_id = 0; /* irrelevant */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
376 entries[0].a_perm = (mode >> 6) & 7; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
377 entries[1].a_type = GROUP_OBJ; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
378 entries[1].a_id = 0; /* irrelevant */ |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
379 entries[1].a_perm = (mode >> 3) & 7; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
380 entries[2].a_type = OTHER_OBJ; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
381 entries[2].a_id = 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
382 entries[2].a_perm = mode & 7; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
383 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
384 if (desc != -1) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
385 ret = facl (desc, SETACL, sizeof (entries) / sizeof (aclent_t), entries); |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
386 else |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
387 ret = acl (name, SETACL, sizeof (entries) / sizeof (aclent_t), entries); |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
388 if (ret < 0) |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
389 { |
12906
05cf771f8b65
copy-acl: enhance Solaris ACL error handling
Ben Walton <bwalton@artsci.utoronto.ca>
parents:
12559
diff
changeset
|
390 if (errno == ENOSYS || errno == EOPNOTSUPP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
391 return chmod_or_fchmod (name, desc, mode); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
392 return -1; |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
393 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
394 } |
10184 | 395 |
10181
5282ccc922b9
Add support for Cygwin ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10180
diff
changeset
|
396 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
|
397 { |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
398 /* 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
|
399 been set. */ |
10179
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
400 return chmod_or_fchmod (name, desc, mode); |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
401 } |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
402 return 0; |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
403 |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
404 # endif |
90f51b86b088
Add support for Solaris 7..10 ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10176
diff
changeset
|
405 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
406 # elif HAVE_GETACL /* HP-UX */ |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
407 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
408 struct stat statbuf; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
409 struct acl_entry entries[3]; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
410 int ret; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
411 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
412 if (desc != -1) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
413 ret = fstat (desc, &statbuf); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
414 else |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
415 ret = stat (name, &statbuf); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
416 if (ret < 0) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
417 return -1; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
418 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
419 entries[0].uid = statbuf.st_uid; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
420 entries[0].gid = ACL_NSGROUP; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
421 entries[0].mode = (mode >> 6) & 7; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
422 entries[1].uid = ACL_NSUSER; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
423 entries[1].gid = statbuf.st_gid; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
424 entries[1].mode = (mode >> 3) & 7; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
425 entries[2].uid = ACL_NSUSER; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
426 entries[2].gid = ACL_NSGROUP; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
427 entries[2].mode = mode & 7; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
428 |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
429 if (desc != -1) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
430 ret = fsetacl (desc, sizeof (entries) / sizeof (struct acl_entry), entries); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
431 else |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
432 ret = setacl (name, sizeof (entries) / sizeof (struct acl_entry), entries); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
433 if (ret < 0) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
434 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
435 if (errno == ENOSYS || errno == EOPNOTSUPP) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
436 return chmod_or_fchmod (name, desc, mode); |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
437 return -1; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
438 } |
10184 | 439 |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
440 if (mode & (S_ISUID | S_ISGID | S_ISVTX)) |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
441 { |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
442 /* 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
|
443 been set. */ |
10182
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
444 return chmod_or_fchmod (name, desc, mode); |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
445 } |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
446 return 0; |
4a177f4b083f
Add support for HP-UX ACLs.
Bruno Haible <bruno@clisp.org>
parents:
10181
diff
changeset
|
447 |
12077
72b0c1288a50
Disable untested support for new flavours of ACLs on AIX.
Bruno Haible <bruno@clisp.org>
parents:
12075
diff
changeset
|
448 # 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
|
449 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
450 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
|
451 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
|
452 acl_type_t type; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
453 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
454 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
|
455 || types.num_entries == 0) |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
456 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
|
457 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
458 /* 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
|
459 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
|
460 type = types.entries[0]; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
461 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
|
462 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
463 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
|
464 int ret; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
465 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
466 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
|
467 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
|
468 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
|
469 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
|
470 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
|
471 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
472 if (desc != -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
473 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
|
474 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
|
475 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
476 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
|
477 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
|
478 if (!(ret < 0 && errno == ENOSYS)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
479 return ret; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
480 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
481 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
|
482 { |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
483 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
|
484 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
|
485 int ret; |
10183 | 486 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
487 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
|
488 u.a.aclEntryN = 0; |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
489 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
|
490 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
491 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
492 ace->aceWho.special_whoid = ACE4_WHO_OWNER; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
493 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
494 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
495 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
496 (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
|
497 | (mode & 0200 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
498 ? 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
|
499 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
500 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
501 | (mode & 0100 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
502 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
503 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
504 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
|
505 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
506 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
507 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
508 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
509 ace->aceWho.special_whoid = ACE4_WHO_GROUP; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
510 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
511 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
512 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
513 (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
|
514 | (mode & 0020 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
515 ? 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
|
516 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
517 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
518 | (mode & 0010 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
519 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
520 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
521 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
|
522 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
523 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
524 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
525 ace->flags = ACE4_ID_SPECIAL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
526 ace->aceWho.special_whoid = ACE4_WHO_EVERYONE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
527 ace->aceType = ACE4_ACCESS_ALLOWED_ACE_TYPE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
528 ace->aceFlags = 0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
529 ace->aceMask = |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
530 (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
|
531 | (mode & 0002 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
532 ? 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
|
533 | ACE4_ADD_SUBDIRECTORY |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
534 : 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
535 | (mode & 0001 ? ACE4_EXECUTE : 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
536 ace->aceWhoString[0] = '\0'; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
537 ace->entryLen = (char *) &ace->aceWhoString[4] - (char *) ace; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
538 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
|
539 u.a.aclEntryN++; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
540 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
541 u.a.aclLength = (char *) ace - (char *) &u.a; |
10183 | 542 |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
543 if (desc != -1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
544 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
|
545 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
|
546 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
547 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
|
548 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
|
549 if (!(ret < 0 && errno == ENOSYS)) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12077
diff
changeset
|
550 return ret; |
12075
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
551 } |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
552 |
c57301f2214b
Add support for new flavours of ACLs on AIX. (Untested.)
Bruno Haible <bruno@clisp.org>
parents:
11917
diff
changeset
|
553 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
|
554 |
10183 | 555 # elif HAVE_STATACL /* older AIX */ |
556 | |
557 union { struct acl a; char room[128]; } u; | |
558 int ret; | |
559 | |
560 u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */ | |
561 u.a.acl_mode = mode & ~(S_IXACL | 0777); | |
562 u.a.u_access = (mode >> 6) & 7; | |
563 u.a.g_access = (mode >> 3) & 7; | |
564 u.a.o_access = mode & 7; | |
565 | |
566 if (desc != -1) | |
567 ret = fchacl (desc, &u.a, u.a.acl_len); | |
568 else | |
569 ret = chacl (name, &u.a, u.a.acl_len); | |
570 | |
571 if (ret < 0 && errno == ENOSYS) | |
572 return chmod_or_fchmod (name, desc, mode); | |
573 | |
574 return ret; | |
575 | |
13757
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
576 # elif HAVE_ACLSORT /* NonStop Kernel */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
577 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
578 struct acl entries[4]; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
579 int ret; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
580 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
581 entries[0].a_type = USER_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
582 entries[0].a_id = 0; /* irrelevant */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
583 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
|
584 entries[1].a_type = GROUP_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
585 entries[1].a_id = 0; /* irrelevant */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
586 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
|
587 entries[2].a_type = CLASS_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
588 entries[2].a_id = 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
589 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
|
590 entries[3].a_type = OTHER_OBJ; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
591 entries[3].a_id = 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
592 entries[3].a_perm = mode & 7; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
593 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
594 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
|
595 if (ret > 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
596 abort (); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
597 if (ret < 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
598 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
599 if (0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
600 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
|
601 return -1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
602 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
603 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
604 ret = acl ((char *) name, ACL_SET, |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
605 sizeof (entries) / sizeof (struct acl), entries); |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
606 if (ret < 0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
607 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
608 if (0) |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
609 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
|
610 return -1; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
611 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
612 |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
613 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
|
614 { |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
615 /* 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
|
616 been set. */ |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
617 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
|
618 } |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
619 return 0; |
87aaf9340686
acl: Add support for ACLs on NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents:
12906
diff
changeset
|
620 |
10155
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
621 # else /* Unknown flavor of ACLs */ |
3df501903792
Simplify #ifs. Put Solaris code after POSIX-like code.
Bruno Haible <bruno@clisp.org>
parents:
10150
diff
changeset
|
622 return chmod_or_fchmod (name, desc, mode); |
10126 | 623 # endif |
624 #else /* !USE_ACL */ | |
625 return chmod_or_fchmod (name, desc, mode); | |
626 #endif | |
627 } | |
628 | |
629 /* As with qset_acl, but also output a diagnostic on failure. */ | |
630 | |
631 int | |
632 set_acl (char const *name, int desc, mode_t mode) | |
633 { | |
634 int r = qset_acl (name, desc, mode); | |
635 if (r != 0) | |
636 error (0, errno, _("setting permissions for %s"), quote (name)); | |
637 return r; | |
638 } |