Annotation of embedaddon/rsync/lib/sysacls.h, revision 1.1.1.2
1.1 misho 1: /*
2: * Unix SMB/Netbios implementation.
3: * Version 2.2.x
4: * Portable SMB ACL interface
5: * Copyright (C) Jeremy Allison 2000
1.1.1.2 ! misho 6: * Copyright (C) 2007-2015 Wayne Davison
1.1 misho 7: *
8: * This program is free software; you can redistribute it and/or modify
9: * it under the terms of the GNU General Public License as published by
10: * the Free Software Foundation; either version 3 of the License, or
11: * (at your option) any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * with this program; if not, visit the http://fsf.org website.
20: */
21:
22: #ifdef SUPPORT_ACLS
23:
24: #ifdef HAVE_SYS_ACL_H
25: #include <sys/acl.h>
26: #endif
27: #ifdef HAVE_ACL_LIBACL_H
28: #include <acl/libacl.h>
29: #endif
30:
31: #define SMB_MALLOC(cnt) new_array(char, cnt)
32: #define SMB_MALLOC_P(obj) new_array(obj, 1)
33: #define SMB_MALLOC_ARRAY(obj, cnt) new_array(obj, cnt)
34: #define SMB_REALLOC(mem, cnt) realloc_array(mem, char, cnt)
35: #define slprintf snprintf
36:
37: #if defined HAVE_POSIX_ACLS /*-----------------------------------------------*/
38:
39: /* This is an identity mapping (just remove the SMB_). */
40:
41: #define SMB_ACL_TAG_T acl_tag_t
42: #define SMB_ACL_TYPE_T acl_type_t
43:
44: /* Types of ACLs. */
45: #define SMB_ACL_USER ACL_USER
46: #define SMB_ACL_USER_OBJ ACL_USER_OBJ
47: #define SMB_ACL_GROUP ACL_GROUP
48: #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
49: #define SMB_ACL_OTHER ACL_OTHER
50: #define SMB_ACL_MASK ACL_MASK
1.1.1.2 ! misho 51: #define SMB_ACL_EVERYONE ACL_EVERYONE
1.1 misho 52:
53: #define SMB_ACL_T acl_t
54:
55: #define SMB_ACL_ENTRY_T acl_entry_t
56:
57: #define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
58: #define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
59:
60: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
61: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
1.1.1.2 ! misho 62: #define SMB_ACL_TYPE_NFS4 ACL_TYPE_NFS4
! 63:
! 64: #define SMB_ACL_BRAND_UNKNOWN ACL_BRAND_UNKNOWN
! 65: #define SMB_ACL_BRAND_POSIX ACL_BRAND_POSIX
! 66: #define SMB_ACL_BRAND_NFS4 ACL_BRAND_NFS4
1.1 misho 67:
68: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
69: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
70:
71: #define SMB_ACL_NEED_SORT
72:
73: #elif defined HAVE_TRU64_ACLS /*---------------------------------------------*/
74:
75: /* This is for DEC/Compaq Tru64 UNIX */
76:
77: #define SMB_ACL_TAG_T acl_tag_t
78: #define SMB_ACL_TYPE_T acl_type_t
79:
80: /* Types of ACLs. */
81: #define SMB_ACL_USER ACL_USER
82: #define SMB_ACL_USER_OBJ ACL_USER_OBJ
83: #define SMB_ACL_GROUP ACL_GROUP
84: #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
85: #define SMB_ACL_OTHER ACL_OTHER
86: #define SMB_ACL_MASK ACL_MASK
87:
88: #define SMB_ACL_T acl_t
89:
90: #define SMB_ACL_ENTRY_T acl_entry_t
91:
92: #define SMB_ACL_FIRST_ENTRY 0
93: #define SMB_ACL_NEXT_ENTRY 1
94:
95: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
96: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
97:
98: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
99: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
100:
101: #define SMB_ACL_NEED_SORT
102:
103: #elif defined HAVE_UNIXWARE_ACLS || defined HAVE_SOLARIS_ACLS /*-------------*/
104:
105: /* Donated by Michael Davidson <md@sco.COM> for UnixWare / OpenUNIX.
106: * Modified by Toomas Soome <tsoome@ut.ee> for Solaris. */
107:
108: /* SVR4.2 ES/MP ACLs */
109: typedef int SMB_ACL_TAG_T;
110: typedef int SMB_ACL_TYPE_T;
111:
112: /* Types of ACLs. */
113: #define SMB_ACL_USER USER
114: #define SMB_ACL_USER_OBJ USER_OBJ
115: #define SMB_ACL_GROUP GROUP
116: #define SMB_ACL_GROUP_OBJ GROUP_OBJ
117: #define SMB_ACL_OTHER OTHER_OBJ
118: #define SMB_ACL_MASK CLASS_OBJ
119:
120: typedef struct SMB_ACL_T {
121: int size;
122: int count;
123: int next;
124: struct acl acl[1];
125: } *SMB_ACL_T;
126:
127: typedef struct acl *SMB_ACL_ENTRY_T;
128:
129: #define SMB_ACL_FIRST_ENTRY 0
130: #define SMB_ACL_NEXT_ENTRY 1
131:
132: #define SMB_ACL_TYPE_ACCESS 0
133: #define SMB_ACL_TYPE_DEFAULT 1
134:
135: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
136: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
137:
138: #define SMB_ACL_NEED_SORT
139:
140: #ifdef __CYGWIN__
141: #define SMB_ACL_LOSES_SPECIAL_MODE_BITS
142: #endif
143:
144: #elif defined HAVE_HPUX_ACLS /*----------------------------------------------*/
145:
146: /* Based on the Solaris & UnixWare code. */
147:
148: #undef GROUP
149: #include <sys/aclv.h>
150:
151: /* SVR4.2 ES/MP ACLs */
152: typedef int SMB_ACL_TAG_T;
153: typedef int SMB_ACL_TYPE_T;
154:
155: /* Types of ACLs. */
156: #define SMB_ACL_USER USER
157: #define SMB_ACL_USER_OBJ USER_OBJ
158: #define SMB_ACL_GROUP GROUP
159: #define SMB_ACL_GROUP_OBJ GROUP_OBJ
160: #define SMB_ACL_OTHER OTHER_OBJ
161: #define SMB_ACL_MASK CLASS_OBJ
162:
163: typedef struct SMB_ACL_T {
164: int size;
165: int count;
166: int next;
167: struct acl acl[1];
168: } *SMB_ACL_T;
169:
170: typedef struct acl *SMB_ACL_ENTRY_T;
171:
172: #define SMB_ACL_FIRST_ENTRY 0
173: #define SMB_ACL_NEXT_ENTRY 1
174:
175: #define SMB_ACL_TYPE_ACCESS 0
176: #define SMB_ACL_TYPE_DEFAULT 1
177:
178: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
179: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
180:
181: #define SMB_ACL_NEED_SORT
182:
183: #elif defined HAVE_IRIX_ACLS /*----------------------------------------------*/
184:
185: /* IRIX ACLs */
186:
187: #define SMB_ACL_TAG_T acl_tag_t
188: #define SMB_ACL_TYPE_T acl_type_t
189:
190: /* Types of ACLs. */
191: #define SMB_ACL_USER ACL_USER
192: #define SMB_ACL_USER_OBJ ACL_USER_OBJ
193: #define SMB_ACL_GROUP ACL_GROUP
194: #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
195: #define SMB_ACL_OTHER ACL_OTHER_OBJ
196: #define SMB_ACL_MASK ACL_MASK
197:
198: typedef struct SMB_ACL_T {
199: int next;
200: BOOL freeaclp;
201: struct acl *aclp;
202: } *SMB_ACL_T;
203:
204: #define SMB_ACL_ENTRY_T acl_entry_t
205:
206: #define SMB_ACL_FIRST_ENTRY 0
207: #define SMB_ACL_NEXT_ENTRY 1
208:
209: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
210: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
211:
212: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
213: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
214:
215: #define SMB_ACL_NEED_SORT
216:
217: #elif defined HAVE_AIX_ACLS /*-----------------------------------------------*/
218:
219: /* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
220:
221: #include "/usr/include/acl.h"
222:
223: struct acl_entry_link{
224: struct acl_entry_link *prevp;
225: struct new_acl_entry *entryp;
226: struct acl_entry_link *nextp;
227: int count;
228: };
229:
230: struct new_acl_entry{
231: unsigned short ace_len;
232: unsigned short ace_type;
233: unsigned int ace_access;
234: struct ace_id ace_id[1];
235: };
236:
237: #define SMB_ACL_ENTRY_T struct new_acl_entry*
238: #define SMB_ACL_T struct acl_entry_link*
239:
240: #define SMB_ACL_TAG_T unsigned short
241: #define SMB_ACL_TYPE_T int
242:
243: /* Types of ACLs. */
244: #define SMB_ACL_USER ACEID_USER
245: #define SMB_ACL_USER_OBJ 3
246: #define SMB_ACL_GROUP ACEID_GROUP
247: #define SMB_ACL_GROUP_OBJ 4
248: #define SMB_ACL_OTHER 5
249: #define SMB_ACL_MASK 6
250:
251: #define SMB_ACL_FIRST_ENTRY 1
252: #define SMB_ACL_NEXT_ENTRY 2
253:
254: #define SMB_ACL_TYPE_ACCESS 0
255: #define SMB_ACL_TYPE_DEFAULT 1
256:
257: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
258: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
259:
260: #define SMB_ACL_NEED_SORT
261:
262: #elif defined(HAVE_OSX_ACLS) /*----------------------------------------------*/
263:
264: /* Special handling for OS X ACLs */
265:
266: #define SMB_ACL_TAG_T acl_tag_t
267: #define SMB_ACL_TYPE_T acl_type_t
268:
269: #define SMB_ACL_T acl_t
270:
271: #define SMB_ACL_ENTRY_T acl_entry_t
272:
273: #define SMB_ACL_USER 1
274: #define SMB_ACL_GROUP 2
275:
276: #define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
277: #define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
278:
279: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_EXTENDED
280: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
281:
282: #define SMB_ACL_VALID_NAME_BITS ((1<<25)-1)
283: #define SMB_ACL_VALID_OBJ_BITS 0
284:
285: /*#undef SMB_ACL_NEED_SORT*/
286:
287: #else /*---------------------------------------------------------------------*/
288:
289: /* Unknown platform. */
290:
291: #error Cannot handle ACLs on this platform!
292:
293: #endif
294:
295: int sys_acl_get_entry(SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
296: int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
297: int sys_acl_get_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T *tag_type_p, uint32 *bits_p, id_t *u_g_id_p);
298: SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
299: SMB_ACL_T sys_acl_get_fd(int fd);
300: SMB_ACL_T sys_acl_init(int count);
1.1.1.2 ! misho 301: int sys_acl_get_brand( SMB_ACL_T the_acl, int *brand_p);
! 302: int sys_acl_get_brand_file( const char *path_p, int *brand_p);
1.1 misho 303: int sys_acl_create_entry(SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
304: int sys_acl_set_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype, uint32 bits, id_t u_g_id);
305: int sys_acl_set_access_bits(SMB_ACL_ENTRY_T entry, uint32 bits);
306: int sys_acl_valid(SMB_ACL_T theacl);
307: int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
308: int sys_acl_set_fd(int fd, SMB_ACL_T theacl);
309: int sys_acl_delete_def_file(const char *name);
310: int sys_acl_free_acl(SMB_ACL_T the_acl);
311: int no_acl_syscall_error(int err);
312:
313: #endif /* SUPPORT_ACLS */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>