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