Fix from Michael Davidson <md@caldera.com> for DEC OSF/1 ACLs (ie.
[tprouty/samba.git] / source / 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_DRAFT13_POSIX_ACLS)
58
59 /* This is for DEC OSF/1 */
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_IRIX_ACLS)
126
127 #define SMB_ACL_TAG_T               acl_tag_t
128 #define SMB_ACL_TYPE_T              acl_type_t
129 #define SMB_ACL_PERMSET_T           acl_permset_t
130 #define SMB_ACL_PERM_T              acl_perm_t
131 #define SMB_ACL_READ                ACL_READ
132 #define SMB_ACL_WRITE               ACL_WRITE
133 #define SMB_ACL_EXECUTE             ACL_EXECUTE
134
135 /* Types of ACLs. */
136 #define SMB_ACL_USER                ACL_USER
137 #define SMB_ACL_USER_OBJ            ACL_USER_OBJ
138 #define SMB_ACL_GROUP               ACL_GROUP
139 #define SMB_ACL_GROUP_OBJ           ACL_GROUP_OBJ
140 #define SMB_ACL_OTHER               ACL_OTHER_OBJ
141 #define SMB_ACL_MASK                ACL_MASK
142
143 typedef struct SMB_ACL_T {
144    int next;
145    BOOL freeaclp;
146    struct acl  *aclp;
147 } *SMB_ACL_T;
148
149 #define SMB_ACL_ENTRY_T             acl_entry_t
150
151 #define SMB_ACL_FIRST_ENTRY         0
152 #define SMB_ACL_NEXT_ENTRY          1
153
154 #define SMB_ACL_TYPE_ACCESS         ACL_TYPE_ACCESS
155 #define SMB_ACL_TYPE_DEFAULT        ACL_TYPE_DEFAULT
156
157 #elif defined(HAVE_AIX_ACLS)
158
159 /* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
160
161 #include "/usr/include/acl.h"
162
163 typedef uint                        *SMB_ACL_PERMSET_T;
164  
165 struct acl_entry_link{
166         struct acl_entry_link *prevp;
167         struct new_acl_entry *entryp;
168         struct acl_entry_link *nextp;
169         int count;
170 };
171
172 struct new_acl_entry{
173         unsigned short  ace_len;
174         unsigned short  ace_type;
175         unsigned int    ace_access;
176         struct ace_id ace_id[1];
177 };
178
179 #define SMB_ACL_ENTRY_T             struct new_acl_entry*
180 #define SMB_ACL_T                   struct acl_entry_link*
181  
182 #define SMB_ACL_TAG_T               unsigned short
183 #define SMB_ACL_TYPE_T              int
184 #define SMB_ACL_PERM_T              uint
185 #define SMB_ACL_READ                S_IRUSR
186 #define SMB_ACL_WRITE               S_IWUSR
187 #define SMB_ACL_EXECUTE             S_IXUSR
188
189 /* Types of ACLs. */
190 #define SMB_ACL_USER                ACEID_USER
191 #define SMB_ACL_USER_OBJ            3
192 #define SMB_ACL_GROUP               ACEID_GROUP
193 #define SMB_ACL_GROUP_OBJ           4
194 #define SMB_ACL_OTHER               5
195 #define SMB_ACL_MASK                6
196
197
198 #define SMB_ACL_FIRST_ENTRY         1
199 #define SMB_ACL_NEXT_ENTRY          2
200
201 #define SMB_ACL_TYPE_ACCESS         0
202 #define SMB_ACL_TYPE_DEFAULT        1
203
204 #else /* No ACLs. */
205
206 /* No ACLS - fake it. */
207 #define SMB_ACL_TAG_T                           int
208 #define SMB_ACL_TYPE_T              int
209 #define SMB_ACL_PERMSET_T                       mode_t
210 #define SMB_ACL_PERM_T                          mode_t
211 #define SMB_ACL_READ                            S_IRUSR
212 #define SMB_ACL_WRITE                           S_IWUSR
213 #define SMB_ACL_EXECUTE                         S_IXUSR
214
215 /* Types of ACLs. */
216 #define SMB_ACL_USER                            0
217 #define SMB_ACL_USER_OBJ                        1
218 #define SMB_ACL_GROUP                           2
219 #define SMB_ACL_GROUP_OBJ                       3
220 #define SMB_ACL_OTHER                           4
221 #define SMB_ACL_MASK                            5
222
223 typedef struct SMB_ACL_T {
224         int dummy;
225 } *SMB_ACL_T;
226
227 typedef struct SMB_ACL_ENTRY_T {
228         int dummy;
229 } *SMB_ACL_ENTRY_T;
230
231 #define SMB_ACL_FIRST_ENTRY                     0
232 #define SMB_ACL_NEXT_ENTRY                      1
233
234 #define SMB_ACL_TYPE_ACCESS                     0
235 #define SMB_ACL_TYPE_DEFAULT            1
236
237 #endif /* No ACLs. */
238 #endif /* _SMB_ACLS_H */