2 * Unix SMB/Netbios implementation.
4 * Portable SMB ACL interface
5 * Copyright (C) Jeremy Allison 2000
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 3 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * with this program; if not, visit the http://fsf.org website.
25 #ifdef HAVE_ACL_LIBACL_H
26 #include <acl/libacl.h>
29 #define SMB_MALLOC(cnt) new_array(char, cnt)
30 #define SMB_MALLOC_P(obj) new_array(obj, 1)
31 #define SMB_MALLOC_ARRAY(obj, cnt) new_array(obj, cnt)
32 #define SMB_REALLOC(mem, cnt) realloc_array(mem, char, cnt)
33 #define slprintf snprintf
35 #if defined HAVE_POSIX_ACLS
37 /* This is an identity mapping (just remove the SMB_). */
39 #define SMB_ACL_TAG_T acl_tag_t
40 #define SMB_ACL_TYPE_T acl_type_t
41 #define SMB_ACL_PERMSET_T acl_permset_t
44 #define SMB_ACL_USER ACL_USER
45 #define SMB_ACL_USER_OBJ ACL_USER_OBJ
46 #define SMB_ACL_GROUP ACL_GROUP
47 #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
48 #define SMB_ACL_OTHER ACL_OTHER
49 #define SMB_ACL_MASK ACL_MASK
51 #define SMB_ACL_T acl_t
53 #define SMB_ACL_ENTRY_T acl_entry_t
55 #define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
56 #define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
58 #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
59 #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
61 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
62 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
64 #define SMB_ACL_NEED_SORT
66 #elif defined HAVE_TRU64_ACLS
68 /* This is for DEC/Compaq Tru64 UNIX */
70 #define SMB_ACL_TAG_T acl_tag_t
71 #define SMB_ACL_TYPE_T acl_type_t
72 #define SMB_ACL_PERMSET_T acl_permset_t
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
82 #define SMB_ACL_T acl_t
84 #define SMB_ACL_ENTRY_T acl_entry_t
86 #define SMB_ACL_FIRST_ENTRY 0
87 #define SMB_ACL_NEXT_ENTRY 1
89 #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
90 #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
92 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
93 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
95 #define SMB_ACL_NEED_SORT
97 #elif defined HAVE_UNIXWARE_ACLS || defined HAVE_SOLARIS_ACLS
99 /* Donated by Michael Davidson <md@sco.COM> for UnixWare / OpenUNIX.
100 * Modified by Toomas Soome <tsoome@ut.ee> for Solaris. */
102 /* SVR4.2 ES/MP ACLs */
103 typedef int SMB_ACL_TAG_T;
104 typedef int SMB_ACL_TYPE_T;
105 typedef ushort *SMB_ACL_PERMSET_T;
108 #define SMB_ACL_USER USER
109 #define SMB_ACL_USER_OBJ USER_OBJ
110 #define SMB_ACL_GROUP GROUP
111 #define SMB_ACL_GROUP_OBJ GROUP_OBJ
112 #define SMB_ACL_OTHER OTHER_OBJ
113 #define SMB_ACL_MASK CLASS_OBJ
115 typedef struct SMB_ACL_T {
122 typedef struct acl *SMB_ACL_ENTRY_T;
124 #define SMB_ACL_FIRST_ENTRY 0
125 #define SMB_ACL_NEXT_ENTRY 1
127 #define SMB_ACL_TYPE_ACCESS 0
128 #define SMB_ACL_TYPE_DEFAULT 1
130 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
131 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
133 #define SMB_ACL_NEED_SORT
136 #define SMB_ACL_LOSES_SPECIAL_MODE_BITS
139 #elif defined HAVE_HPUX_ACLS
141 /* Based on the Solaris & UnixWare code. */
144 #include <sys/aclv.h>
146 /* SVR4.2 ES/MP ACLs */
147 typedef int SMB_ACL_TAG_T;
148 typedef int SMB_ACL_TYPE_T;
149 typedef ushort *SMB_ACL_PERMSET_T;
152 #define SMB_ACL_USER USER
153 #define SMB_ACL_USER_OBJ USER_OBJ
154 #define SMB_ACL_GROUP GROUP
155 #define SMB_ACL_GROUP_OBJ GROUP_OBJ
156 #define SMB_ACL_OTHER OTHER_OBJ
157 #define SMB_ACL_MASK CLASS_OBJ
159 typedef struct SMB_ACL_T {
166 typedef struct acl *SMB_ACL_ENTRY_T;
168 #define SMB_ACL_FIRST_ENTRY 0
169 #define SMB_ACL_NEXT_ENTRY 1
171 #define SMB_ACL_TYPE_ACCESS 0
172 #define SMB_ACL_TYPE_DEFAULT 1
174 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
175 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
177 #define SMB_ACL_NEED_SORT
179 #elif defined HAVE_IRIX_ACLS
183 #define SMB_ACL_TAG_T acl_tag_t
184 #define SMB_ACL_TYPE_T acl_type_t
185 #define SMB_ACL_PERMSET_T acl_permset_t
188 #define SMB_ACL_USER ACL_USER
189 #define SMB_ACL_USER_OBJ ACL_USER_OBJ
190 #define SMB_ACL_GROUP ACL_GROUP
191 #define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
192 #define SMB_ACL_OTHER ACL_OTHER_OBJ
193 #define SMB_ACL_MASK ACL_MASK
195 typedef struct SMB_ACL_T {
201 #define SMB_ACL_ENTRY_T acl_entry_t
203 #define SMB_ACL_FIRST_ENTRY 0
204 #define SMB_ACL_NEXT_ENTRY 1
206 #define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
207 #define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
209 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
210 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
212 #define SMB_ACL_NEED_SORT
214 #elif defined HAVE_AIX_ACLS
216 /* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
218 #include "/usr/include/acl.h"
220 typedef uint *SMB_ACL_PERMSET_T;
222 struct acl_entry_link{
223 struct acl_entry_link *prevp;
224 struct new_acl_entry *entryp;
225 struct acl_entry_link *nextp;
229 struct new_acl_entry{
230 unsigned short ace_len;
231 unsigned short ace_type;
232 unsigned int ace_access;
233 struct ace_id ace_id[1];
236 #define SMB_ACL_ENTRY_T struct new_acl_entry*
237 #define SMB_ACL_T struct acl_entry_link*
239 #define SMB_ACL_TAG_T unsigned short
240 #define SMB_ACL_TYPE_T int
243 #define SMB_ACL_USER ACEID_USER
244 #define SMB_ACL_USER_OBJ 3
245 #define SMB_ACL_GROUP ACEID_GROUP
246 #define SMB_ACL_GROUP_OBJ 4
247 #define SMB_ACL_OTHER 5
248 #define SMB_ACL_MASK 6
251 #define SMB_ACL_FIRST_ENTRY 1
252 #define SMB_ACL_NEXT_ENTRY 2
254 #define SMB_ACL_TYPE_ACCESS 0
255 #define SMB_ACL_TYPE_DEFAULT 1
257 #define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
258 #define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
260 #define SMB_ACL_NEED_SORT
264 /* Unknown platform. */
266 #error Cannot handle ACLs on this platform!
270 int sys_acl_get_entry(SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
271 int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
272 int sys_acl_get_access_bits(SMB_ACL_ENTRY_T entry_d, uint32 *bits);
273 void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
274 SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
275 SMB_ACL_T sys_acl_get_fd(int fd);
276 SMB_ACL_T sys_acl_init(int count);
277 int sys_acl_create_entry(SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
278 int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype);
279 int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry, void *qual);
280 int sys_acl_set_access_bits(SMB_ACL_ENTRY_T entry, uint32 bits);
281 int sys_acl_valid(SMB_ACL_T theacl);
282 int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
283 int sys_acl_set_fd(int fd, SMB_ACL_T theacl);
284 int sys_acl_delete_def_file(const char *name);
285 int sys_acl_free_acl(SMB_ACL_T the_acl);
286 int sys_acl_free_qualifier(void *qual, SMB_ACL_TAG_T tagtype);
287 int no_acl_syscall_error(int err);
289 #endif /* SUPPORT_ACLS */