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