53adf39dbc5fb144da2fd58b7cf9ca3b7a2dc2e9
[sharpe/samba-autobuild/.git] / source3 / include / smb_acls.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 2.2.x
4    Portable SMB ACL interface
5    Copyright (C) Jeremy Allison 2000
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _SMB_ACLS_H
23 #define _SMB_ACLS_H
24
25 #include "includes.h"
26
27 #if defined(HAVE_POSIX_ACLS)
28
29 /* This is an identity mapping (just remove the SMB_). */
30
31 #define SMB_ACL_TAG_T               acl_tag_t
32 #define SMB_ACL_TYPE_T                          acl_type_t
33 #define SMB_ACL_PERMSET_T           acl_permset_t
34 #define SMB_ACL_PERM_T                          acl_perm_t
35 #define SMB_ACL_READ                ACL_READ
36 #define SMB_ACL_WRITE               ACL_WRITE
37 #define SMB_ACL_EXECUTE             ACL_EXECUTE
38
39 /* Types of ACLs. */
40 #define SMB_ACL_USER                ACL_USER
41 #define SMB_ACL_USER_OBJ            ACL_USER_OBJ
42 #define SMB_ACL_GROUP               ACL_GROUP
43 #define SMB_ACL_GROUP_OBJ           ACL_GROUP_OBJ
44 #define SMB_ACL_OTHER               ACL_OTHER
45 #define SMB_ACL_MASK                ACL_MASK
46
47 #define SMB_ACL_T                                       acl_t
48
49 #define SMB_ACL_ENTRY_T                         acl_entry_t
50
51 #define SMB_ACL_FIRST_ENTRY         ACL_FIRST_ENTRY
52 #define SMB_ACL_NEXT_ENTRY          ACL_NEXT_ENTRY
53
54 #define SMB_ACL_TYPE_ACCESS         ACL_TYPE_ACCESS
55 #define SMB_ACL_TYPE_DEFAULT        ACL_TYPE_DEFAULT
56
57 #elif defined(HAVE_TRU64_ACLS)
58
59 /* This is for DEC/Compaq Tru64 UNIX */
60
61 #define SMB_ACL_TAG_T               acl_tag_t
62 #define SMB_ACL_TYPE_T                          acl_type_t
63 #define SMB_ACL_PERMSET_T           acl_permset_t
64 #define SMB_ACL_PERM_T                          acl_perm_t
65 #define SMB_ACL_READ                ACL_READ
66 #define SMB_ACL_WRITE               ACL_WRITE
67 #define SMB_ACL_EXECUTE             ACL_EXECUTE
68
69 /* Types of ACLs. */
70 #define SMB_ACL_USER                ACL_USER
71 #define SMB_ACL_USER_OBJ            ACL_USER_OBJ
72 #define SMB_ACL_GROUP               ACL_GROUP
73 #define SMB_ACL_GROUP_OBJ           ACL_GROUP_OBJ
74 #define SMB_ACL_OTHER               ACL_OTHER
75 #define SMB_ACL_MASK                ACL_MASK
76
77 #define SMB_ACL_T                                       acl_t
78
79 #define SMB_ACL_ENTRY_T                         acl_entry_t
80
81 #define SMB_ACL_FIRST_ENTRY         0
82 #define SMB_ACL_NEXT_ENTRY          1
83
84 #define SMB_ACL_TYPE_ACCESS         ACL_TYPE_ACCESS
85 #define SMB_ACL_TYPE_DEFAULT        ACL_TYPE_DEFAULT
86
87 #elif defined(HAVE_UNIXWARE_ACLS) || defined(HAVE_SOLARIS_ACLS)
88 /*
89  * Donated by Michael Davidson <md@sco.COM> for UnixWare / OpenUNIX.
90  * Modified by Toomas Soome <tsoome@ut.ee> for Solaris.
91  */
92
93 /* SVR4.2 ES/MP ACLs */
94 typedef int                     SMB_ACL_TAG_T;
95 typedef int                     SMB_ACL_TYPE_T;
96 typedef ushort          *SMB_ACL_PERMSET_T;
97 typedef ushort          SMB_ACL_PERM_T;
98 #define SMB_ACL_READ                            4
99 #define SMB_ACL_WRITE                           2
100 #define SMB_ACL_EXECUTE                         1
101
102 /* Types of ACLs. */
103 #define SMB_ACL_USER                            USER
104 #define SMB_ACL_USER_OBJ                        USER_OBJ
105 #define SMB_ACL_GROUP                           GROUP
106 #define SMB_ACL_GROUP_OBJ                       GROUP_OBJ
107 #define SMB_ACL_OTHER                           OTHER_OBJ
108 #define SMB_ACL_MASK                            CLASS_OBJ
109
110 typedef struct SMB_ACL_T {
111         int     size;
112         int     count;
113         int     next;
114         struct acl      acl[1];
115 } *SMB_ACL_T;
116
117 typedef struct acl                                      *SMB_ACL_ENTRY_T;
118
119 #define SMB_ACL_FIRST_ENTRY                     0
120 #define SMB_ACL_NEXT_ENTRY                      1
121
122 #define SMB_ACL_TYPE_ACCESS                     0
123 #define SMB_ACL_TYPE_DEFAULT            1
124
125 #elif defined(HAVE_HPUX_ACLS)
126
127 /*
128  * Based on the Solaris & UnixWare code.
129  */
130
131 #undef GROUP
132 #include <sys/aclv.h>
133
134 /* SVR4.2 ES/MP ACLs */
135 typedef int                     SMB_ACL_TAG_T;
136 typedef int                     SMB_ACL_TYPE_T;
137 typedef ushort          *SMB_ACL_PERMSET_T;
138 typedef ushort          SMB_ACL_PERM_T;
139 #define SMB_ACL_READ                            4
140 #define SMB_ACL_WRITE                           2
141 #define SMB_ACL_EXECUTE                         1
142
143 /* Types of ACLs. */
144 #define SMB_ACL_USER                            USER
145 #define SMB_ACL_USER_OBJ                        USER_OBJ
146 #define SMB_ACL_GROUP                           GROUP
147 #define SMB_ACL_GROUP_OBJ                       GROUP_OBJ
148 #define SMB_ACL_OTHER                           OTHER_OBJ
149 #define SMB_ACL_MASK                            CLASS_OBJ
150
151 typedef struct SMB_ACL_T {
152         int     size;
153         int     count;
154         int     next;
155         struct acl      acl[1];
156 } *SMB_ACL_T;
157
158 typedef struct acl                                      *SMB_ACL_ENTRY_T;
159
160 #define SMB_ACL_FIRST_ENTRY                     0
161 #define SMB_ACL_NEXT_ENTRY                      1
162
163 #define SMB_ACL_TYPE_ACCESS                     0
164 #define SMB_ACL_TYPE_DEFAULT            1
165
166 #elif defined(HAVE_IRIX_ACLS)
167
168 #define SMB_ACL_TAG_T               acl_tag_t
169 #define SMB_ACL_TYPE_T              acl_type_t
170 #define SMB_ACL_PERMSET_T           acl_permset_t
171 #define SMB_ACL_PERM_T              acl_perm_t
172 #define SMB_ACL_READ                ACL_READ
173 #define SMB_ACL_WRITE               ACL_WRITE
174 #define SMB_ACL_EXECUTE             ACL_EXECUTE
175
176 /* Types of ACLs. */
177 #define SMB_ACL_USER                ACL_USER
178 #define SMB_ACL_USER_OBJ            ACL_USER_OBJ
179 #define SMB_ACL_GROUP               ACL_GROUP
180 #define SMB_ACL_GROUP_OBJ           ACL_GROUP_OBJ
181 #define SMB_ACL_OTHER               ACL_OTHER_OBJ
182 #define SMB_ACL_MASK                ACL_MASK
183
184 typedef struct SMB_ACL_T {
185    int next;
186    BOOL freeaclp;
187    struct acl  *aclp;
188 } *SMB_ACL_T;
189
190 #define SMB_ACL_ENTRY_T             acl_entry_t
191
192 #define SMB_ACL_FIRST_ENTRY         0
193 #define SMB_ACL_NEXT_ENTRY          1
194
195 #define SMB_ACL_TYPE_ACCESS         ACL_TYPE_ACCESS
196 #define SMB_ACL_TYPE_DEFAULT        ACL_TYPE_DEFAULT
197
198 #elif defined(HAVE_AIX_ACLS)
199
200 /* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
201
202 #include "/usr/include/acl.h"
203
204 typedef uint                        *SMB_ACL_PERMSET_T;
205  
206 struct acl_entry_link{
207         struct acl_entry_link *prevp;
208         struct new_acl_entry *entryp;
209         struct acl_entry_link *nextp;
210         int count;
211 };
212
213 struct new_acl_entry{
214         unsigned short  ace_len;
215         unsigned short  ace_type;
216         unsigned int    ace_access;
217         struct ace_id ace_id[1];
218 };
219
220 #define SMB_ACL_ENTRY_T             struct new_acl_entry*
221 #define SMB_ACL_T                   struct acl_entry_link*
222  
223 #define SMB_ACL_TAG_T               unsigned short
224 #define SMB_ACL_TYPE_T              int
225 #define SMB_ACL_PERM_T              uint
226 #define SMB_ACL_READ                S_IRUSR
227 #define SMB_ACL_WRITE               S_IWUSR
228 #define SMB_ACL_EXECUTE             S_IXUSR
229
230 /* Types of ACLs. */
231 #define SMB_ACL_USER                ACEID_USER
232 #define SMB_ACL_USER_OBJ            3
233 #define SMB_ACL_GROUP               ACEID_GROUP
234 #define SMB_ACL_GROUP_OBJ           4
235 #define SMB_ACL_OTHER               5
236 #define SMB_ACL_MASK                6
237
238
239 #define SMB_ACL_FIRST_ENTRY         1
240 #define SMB_ACL_NEXT_ENTRY          2
241
242 #define SMB_ACL_TYPE_ACCESS         0
243 #define SMB_ACL_TYPE_DEFAULT        1
244
245 #else /* No ACLs. */
246
247 /* No ACLS - fake it. */
248 #define SMB_ACL_TAG_T                           int
249 #define SMB_ACL_TYPE_T              int
250 #define SMB_ACL_PERMSET_T                       mode_t
251 #define SMB_ACL_PERM_T                          mode_t
252 #define SMB_ACL_READ                            S_IRUSR
253 #define SMB_ACL_WRITE                           S_IWUSR
254 #define SMB_ACL_EXECUTE                         S_IXUSR
255
256 /* Types of ACLs. */
257 #define SMB_ACL_USER                            0
258 #define SMB_ACL_USER_OBJ                        1
259 #define SMB_ACL_GROUP                           2
260 #define SMB_ACL_GROUP_OBJ                       3
261 #define SMB_ACL_OTHER                           4
262 #define SMB_ACL_MASK                            5
263
264 typedef struct SMB_ACL_T {
265         int dummy;
266 } *SMB_ACL_T;
267
268 typedef struct SMB_ACL_ENTRY_T {
269         int dummy;
270 } *SMB_ACL_ENTRY_T;
271
272 #define SMB_ACL_FIRST_ENTRY                     0
273 #define SMB_ACL_NEXT_ENTRY                      1
274
275 #define SMB_ACL_TYPE_ACCESS                     0
276 #define SMB_ACL_TYPE_DEFAULT            1
277
278 #endif /* No ACLs. */
279 #endif /* _SMB_ACLS_H */