Annotation of embedaddon/rsync/lib/sysacls.h, revision 1.1.1.1
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
6: * Copyright (C) 2007-2008 Wayne Davison
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
51:
52: #define SMB_ACL_T acl_t
53:
54: #define SMB_ACL_ENTRY_T acl_entry_t
55:
56: #define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
57: #define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
58:
59: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
60: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
61:
62: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
63: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
64:
65: #define SMB_ACL_NEED_SORT
66:
67: #elif defined HAVE_TRU64_ACLS /*---------------------------------------------*/
68:
69: /* This is for DEC/Compaq Tru64 UNIX */
70:
71: #define SMB_ACL_TAG_T acl_tag_t
72: #define SMB_ACL_TYPE_T acl_type_t
73:
74: /* Types of ACLs. */
75: #define SMB_ACL_USER ACL_USER
76: #define SMB_ACL_USER_OBJ ACL_USER_OBJ
77: #define SMB_ACL_GROUP ACL_GROUP
78: #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
79: #define SMB_ACL_OTHER ACL_OTHER
80: #define SMB_ACL_MASK ACL_MASK
81:
82: #define SMB_ACL_T acl_t
83:
84: #define SMB_ACL_ENTRY_T acl_entry_t
85:
86: #define SMB_ACL_FIRST_ENTRY 0
87: #define SMB_ACL_NEXT_ENTRY 1
88:
89: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
90: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
91:
92: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
93: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
94:
95: #define SMB_ACL_NEED_SORT
96:
97: #elif defined HAVE_UNIXWARE_ACLS || defined HAVE_SOLARIS_ACLS /*-------------*/
98:
99: /* Donated by Michael Davidson <md@sco.COM> for UnixWare / OpenUNIX.
100: * Modified by Toomas Soome <tsoome@ut.ee> for Solaris. */
101:
102: /* SVR4.2 ES/MP ACLs */
103: typedef int SMB_ACL_TAG_T;
104: typedef int SMB_ACL_TYPE_T;
105:
106: /* Types of ACLs. */
107: #define SMB_ACL_USER USER
108: #define SMB_ACL_USER_OBJ USER_OBJ
109: #define SMB_ACL_GROUP GROUP
110: #define SMB_ACL_GROUP_OBJ GROUP_OBJ
111: #define SMB_ACL_OTHER OTHER_OBJ
112: #define SMB_ACL_MASK CLASS_OBJ
113:
114: typedef struct SMB_ACL_T {
115: int size;
116: int count;
117: int next;
118: struct acl acl[1];
119: } *SMB_ACL_T;
120:
121: typedef struct acl *SMB_ACL_ENTRY_T;
122:
123: #define SMB_ACL_FIRST_ENTRY 0
124: #define SMB_ACL_NEXT_ENTRY 1
125:
126: #define SMB_ACL_TYPE_ACCESS 0
127: #define SMB_ACL_TYPE_DEFAULT 1
128:
129: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
130: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
131:
132: #define SMB_ACL_NEED_SORT
133:
134: #ifdef __CYGWIN__
135: #define SMB_ACL_LOSES_SPECIAL_MODE_BITS
136: #endif
137:
138: #elif defined HAVE_HPUX_ACLS /*----------------------------------------------*/
139:
140: /* Based on the Solaris & UnixWare code. */
141:
142: #undef GROUP
143: #include <sys/aclv.h>
144:
145: /* SVR4.2 ES/MP ACLs */
146: typedef int SMB_ACL_TAG_T;
147: typedef int SMB_ACL_TYPE_T;
148:
149: /* Types of ACLs. */
150: #define SMB_ACL_USER USER
151: #define SMB_ACL_USER_OBJ USER_OBJ
152: #define SMB_ACL_GROUP GROUP
153: #define SMB_ACL_GROUP_OBJ GROUP_OBJ
154: #define SMB_ACL_OTHER OTHER_OBJ
155: #define SMB_ACL_MASK CLASS_OBJ
156:
157: typedef struct SMB_ACL_T {
158: int size;
159: int count;
160: int next;
161: struct acl acl[1];
162: } *SMB_ACL_T;
163:
164: typedef struct acl *SMB_ACL_ENTRY_T;
165:
166: #define SMB_ACL_FIRST_ENTRY 0
167: #define SMB_ACL_NEXT_ENTRY 1
168:
169: #define SMB_ACL_TYPE_ACCESS 0
170: #define SMB_ACL_TYPE_DEFAULT 1
171:
172: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
173: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
174:
175: #define SMB_ACL_NEED_SORT
176:
177: #elif defined HAVE_IRIX_ACLS /*----------------------------------------------*/
178:
179: /* IRIX ACLs */
180:
181: #define SMB_ACL_TAG_T acl_tag_t
182: #define SMB_ACL_TYPE_T acl_type_t
183:
184: /* Types of ACLs. */
185: #define SMB_ACL_USER ACL_USER
186: #define SMB_ACL_USER_OBJ ACL_USER_OBJ
187: #define SMB_ACL_GROUP ACL_GROUP
188: #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
189: #define SMB_ACL_OTHER ACL_OTHER_OBJ
190: #define SMB_ACL_MASK ACL_MASK
191:
192: typedef struct SMB_ACL_T {
193: int next;
194: BOOL freeaclp;
195: struct acl *aclp;
196: } *SMB_ACL_T;
197:
198: #define SMB_ACL_ENTRY_T acl_entry_t
199:
200: #define SMB_ACL_FIRST_ENTRY 0
201: #define SMB_ACL_NEXT_ENTRY 1
202:
203: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
204: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
205:
206: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
207: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
208:
209: #define SMB_ACL_NEED_SORT
210:
211: #elif defined HAVE_AIX_ACLS /*-----------------------------------------------*/
212:
213: /* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
214:
215: #include "/usr/include/acl.h"
216:
217: struct acl_entry_link{
218: struct acl_entry_link *prevp;
219: struct new_acl_entry *entryp;
220: struct acl_entry_link *nextp;
221: int count;
222: };
223:
224: struct new_acl_entry{
225: unsigned short ace_len;
226: unsigned short ace_type;
227: unsigned int ace_access;
228: struct ace_id ace_id[1];
229: };
230:
231: #define SMB_ACL_ENTRY_T struct new_acl_entry*
232: #define SMB_ACL_T struct acl_entry_link*
233:
234: #define SMB_ACL_TAG_T unsigned short
235: #define SMB_ACL_TYPE_T int
236:
237: /* Types of ACLs. */
238: #define SMB_ACL_USER ACEID_USER
239: #define SMB_ACL_USER_OBJ 3
240: #define SMB_ACL_GROUP ACEID_GROUP
241: #define SMB_ACL_GROUP_OBJ 4
242: #define SMB_ACL_OTHER 5
243: #define SMB_ACL_MASK 6
244:
245: #define SMB_ACL_FIRST_ENTRY 1
246: #define SMB_ACL_NEXT_ENTRY 2
247:
248: #define SMB_ACL_TYPE_ACCESS 0
249: #define SMB_ACL_TYPE_DEFAULT 1
250:
251: #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
252: #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
253:
254: #define SMB_ACL_NEED_SORT
255:
256: #elif defined(HAVE_OSX_ACLS) /*----------------------------------------------*/
257:
258: /* Special handling for OS X ACLs */
259:
260: #define SMB_ACL_TAG_T acl_tag_t
261: #define SMB_ACL_TYPE_T acl_type_t
262:
263: #define SMB_ACL_T acl_t
264:
265: #define SMB_ACL_ENTRY_T acl_entry_t
266:
267: #define SMB_ACL_USER 1
268: #define SMB_ACL_GROUP 2
269:
270: #define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
271: #define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
272:
273: #define SMB_ACL_TYPE_ACCESS ACL_TYPE_EXTENDED
274: #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
275:
276: #define SMB_ACL_VALID_NAME_BITS ((1<<25)-1)
277: #define SMB_ACL_VALID_OBJ_BITS 0
278:
279: /*#undef SMB_ACL_NEED_SORT*/
280:
281: #else /*---------------------------------------------------------------------*/
282:
283: /* Unknown platform. */
284:
285: #error Cannot handle ACLs on this platform!
286:
287: #endif
288:
289: int sys_acl_get_entry(SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
290: int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
291: 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);
292: SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
293: SMB_ACL_T sys_acl_get_fd(int fd);
294: SMB_ACL_T sys_acl_init(int count);
295: int sys_acl_create_entry(SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
296: int sys_acl_set_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype, uint32 bits, id_t u_g_id);
297: int sys_acl_set_access_bits(SMB_ACL_ENTRY_T entry, uint32 bits);
298: int sys_acl_valid(SMB_ACL_T theacl);
299: int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
300: int sys_acl_set_fd(int fd, SMB_ACL_T theacl);
301: int sys_acl_delete_def_file(const char *name);
302: int sys_acl_free_acl(SMB_ACL_T the_acl);
303: int no_acl_syscall_error(int err);
304:
305: #endif /* SUPPORT_ACLS */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>