This source file includes following definitions.
- rpl_acl_get_fd
- rpl_acl_set_fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include "acl.h"
21
22 #include <stdbool.h>
23 #include <stdlib.h>
24
25
26 #if HAVE_SYS_ACL_H
27 # include <sys/acl.h>
28 #endif
29 #if defined HAVE_FACL && ! defined GETACLCNT && defined ACL_CNT
30 # define GETACLCNT ACL_CNT
31 #endif
32
33
34
35 #ifdef HAVE_ACL_LIBACL_H
36 # include <acl/libacl.h>
37 #endif
38
39
40 #if HAVE_ACLV_H
41 # include <sys/types.h>
42 # include <aclv.h>
43
44 extern int acl (char *, int, int, struct acl *);
45 extern int aclsort (int, int, struct acl *);
46 #endif
47
48 #include <errno.h>
49
50 #include <limits.h>
51 #ifndef MIN
52 # define MIN(a,b) ((a) < (b) ? (a) : (b))
53 #endif
54
55 #ifndef SIZE_MAX
56 # define SIZE_MAX ((size_t) -1)
57 #endif
58
59 #ifndef HAVE_FCHMOD
60 # define HAVE_FCHMOD false
61 # define fchmod(fd, mode) (-1)
62 #endif
63
64 #ifndef _GL_INLINE_HEADER_BEGIN
65 #error "Please include config.h first."
66 #endif
67 _GL_INLINE_HEADER_BEGIN
68 #ifndef ACL_INTERNAL_INLINE
69 # define ACL_INTERNAL_INLINE _GL_INLINE
70 #endif
71
72 #if USE_ACL
73
74 # if HAVE_ACL_GET_FILE
75
76
77
78 # ifndef MIN_ACL_ENTRIES
79 # define MIN_ACL_ENTRIES 4
80 # endif
81
82
83 # ifdef HAVE_ACL_GET_FD
84
85
86 # if HAVE_ACL_FREE_TEXT
87 ACL_INTERNAL_INLINE acl_t
88 rpl_acl_get_fd (int fd)
89 {
90 return acl_get_fd (fd, ACL_TYPE_ACCESS);
91 }
92 # undef acl_get_fd
93 # define acl_get_fd rpl_acl_get_fd
94 # endif
95 # else
96 # define HAVE_ACL_GET_FD false
97 # undef acl_get_fd
98 # define acl_get_fd(fd) (NULL)
99 # endif
100
101
102 # ifdef HAVE_ACL_SET_FD
103
104
105 # if HAVE_ACL_FREE_TEXT
106 ACL_INTERNAL_INLINE int
107 rpl_acl_set_fd (int fd, acl_t acl)
108 {
109 return acl_set_fd (fd, ACL_TYPE_ACCESS, acl);
110 }
111 # undef acl_set_fd
112 # define acl_set_fd rpl_acl_set_fd
113 # endif
114 # else
115 # define HAVE_ACL_SET_FD false
116 # undef acl_set_fd
117 # define acl_set_fd(fd, acl) (-1)
118 # endif
119
120
121 # if ! HAVE_ACL_FREE_TEXT
122 # define acl_free_text(buf) acl_free (buf)
123 # endif
124
125
126
127
128 # if !defined HAVE_ACL_EXTENDED_FILE || defined __CYGWIN__
129 # undef HAVE_ACL_EXTENDED_FILE
130 # define HAVE_ACL_EXTENDED_FILE false
131 # define acl_extended_file(name) (-1)
132 # endif
133
134 # if ! defined HAVE_ACL_FROM_MODE && ! defined HAVE_ACL_FROM_TEXT
135 # define acl_from_mode (NULL)
136 # endif
137
138
139 # if (HAVE_ACL_COPY_EXT_NATIVE && HAVE_ACL_CREATE_ENTRY_NP) || defined __sgi
140 # define MODE_INSIDE_ACL 0
141 # endif
142
143
144
145
146 # if !HAVE_ACL_ENTRIES
147 # define acl_entries rpl_acl_entries
148 extern int acl_entries (acl_t);
149 # endif
150
151 # if HAVE_ACL_TYPE_EXTENDED
152
153
154
155 extern int acl_extended_nontrivial (acl_t);
156 # else
157
158
159
160
161 extern int acl_access_nontrivial (acl_t);
162
163
164
165
166
167 extern int acl_default_nontrivial (acl_t);
168 # endif
169
170 # elif HAVE_FACL && defined GETACL
171
172
173 # if defined __CYGWIN__
174 # define MODE_INSIDE_ACL 0
175 # endif
176
177
178
179 extern int acl_nontrivial (int count, aclent_t *entries) _GL_ATTRIBUTE_PURE;
180
181 # ifdef ACE_GETACL
182
183
184
185
186 extern int acl_ace_nontrivial (int count, ace_t *entries) _GL_ATTRIBUTE_PURE;
187
188
189
190
191 # define OLD_ALLOW 0
192 # define OLD_DENY 1
193 # define NEW_ACE_ACCESS_ALLOWED_ACE_TYPE 0
194 # define NEW_ACE_ACCESS_DENIED_ACE_TYPE 1
195
196 # define OLD_ACE_OWNER 0x0100
197 # define OLD_ACE_GROUP 0x0200
198 # define OLD_ACE_OTHER 0x0400
199 # define NEW_ACE_OWNER 0x1000
200 # define NEW_ACE_GROUP 0x2000
201 # define NEW_ACE_IDENTIFIER_GROUP 0x0040
202 # define NEW_ACE_EVERYONE 0x4000
203
204 # define NEW_ACE_READ_DATA 0x001
205 # define NEW_ACE_WRITE_DATA 0x002
206 # define NEW_ACE_APPEND_DATA 0x004
207 # define NEW_ACE_READ_NAMED_ATTRS 0x008
208 # define NEW_ACE_WRITE_NAMED_ATTRS 0x010
209 # define NEW_ACE_EXECUTE 0x020
210 # define NEW_ACE_DELETE_CHILD 0x040
211 # define NEW_ACE_READ_ATTRIBUTES 0x080
212 # define NEW_ACE_WRITE_ATTRIBUTES 0x100
213 # define NEW_ACE_DELETE 0x10000
214 # define NEW_ACE_READ_ACL 0x20000
215 # define NEW_ACE_WRITE_ACL 0x40000
216 # define NEW_ACE_WRITE_OWNER 0x80000
217 # define NEW_ACE_SYNCHRONIZE 0x100000
218
219 # endif
220
221 # elif HAVE_GETACL
222
223
224
225 extern int acl_nontrivial (int count, struct acl_entry *entries);
226
227 # if HAVE_ACLV_H
228
229
230
231 extern int aclv_nontrivial (int count, struct acl *entries);
232
233 # endif
234
235 # elif HAVE_ACLX_GET && 0
236
237
238
239 # elif HAVE_STATACL
240
241
242
243 extern int acl_nontrivial (struct acl *a);
244
245 # elif HAVE_ACLSORT
246
247
248
249 extern int acl_nontrivial (int count, struct acl *entries);
250
251 # endif
252
253
254 # ifndef MODE_INSIDE_ACL
255 # define MODE_INSIDE_ACL 1
256 # endif
257
258 #endif
259
260 struct permission_context {
261 mode_t mode;
262 #if USE_ACL
263 # if HAVE_ACL_GET_FILE
264 acl_t acl;
265 # if !HAVE_ACL_TYPE_EXTENDED
266 acl_t default_acl;
267 # endif
268 bool acls_not_supported;
269
270 # elif defined GETACL
271 int count;
272 aclent_t *entries;
273 # ifdef ACE_GETACL
274 int ace_count;
275 ace_t *ace_entries;
276 # endif
277
278 # elif HAVE_GETACL
279 struct acl_entry entries[NACLENTRIES];
280 int count;
281 # if HAVE_ACLV_H
282 struct acl aclv_entries[NACLVENTRIES];
283 int aclv_count;
284 # endif
285
286 # elif HAVE_STATACL
287 union { struct acl a; char room[4096]; } u;
288 bool have_u;
289
290 # elif HAVE_ACLSORT
291 struct acl entries[NACLENTRIES];
292 int count;
293
294 # endif
295 #endif
296 };
297
298 int get_permissions (const char *, int, mode_t, struct permission_context *);
299 int set_permissions (struct permission_context *, const char *, int);
300 void free_permission_context (struct permission_context *);
301
302 _GL_INLINE_HEADER_END