Print this page
NEX-1767 ls is unable to display SIDs
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
OS-139 POSIX write should imply DELETE_CHILD on directories - and some additional considerations
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/acl.h
+++ new/usr/src/uts/common/sys/acl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 23 *
24 24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 *
27 - * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
27 + * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
28 28 * Copyright 2017 RackTop Systems.
29 29 */
30 30
31 31 #ifndef _SYS_ACL_H
32 32 #define _SYS_ACL_H
33 33
34 34 #include <sys/types.h>
35 35 #include <sys/acl_impl.h>
36 36
37 37 #ifdef __cplusplus
38 38 extern "C" {
39 39 #endif
40 40
41 41 #define MAX_ACL_ENTRIES (1024) /* max entries of each type */
42 42 typedef struct acl {
43 43 int a_type; /* the type of ACL entry */
44 44 uid_t a_id; /* the entry in -uid or gid */
45 45 o_mode_t a_perm; /* the permission field */
46 46 } aclent_t;
47 47
48 48 typedef struct ace {
49 49 uid_t a_who; /* uid or gid */
50 50 uint32_t a_access_mask; /* read,write,... */
51 51 uint16_t a_flags; /* see below */
52 52 uint16_t a_type; /* allow or deny */
53 53 } ace_t;
54 54
55 55 typedef struct acl_info acl_t;
56 56
57 57 /*
58 58 * The following are Defined types for an aclent_t.
59 59 */
60 60 #define USER_OBJ (0x01) /* object owner */
61 61 #define USER (0x02) /* additional users */
62 62 #define GROUP_OBJ (0x04) /* owning group of the object */
63 63 #define GROUP (0x08) /* additional groups */
64 64 #define CLASS_OBJ (0x10) /* file group class and mask entry */
65 65 #define OTHER_OBJ (0x20) /* other entry for the object */
66 66 #define ACL_DEFAULT (0x1000) /* default flag */
67 67 /* default object owner */
68 68 #define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ)
69 69 /* default additional users */
70 70 #define DEF_USER (ACL_DEFAULT | USER)
71 71 /* default owning group */
72 72 #define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ)
73 73 /* default additional groups */
74 74 #define DEF_GROUP (ACL_DEFAULT | GROUP)
75 75 /* default mask entry */
76 76 #define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ)
77 77 /* default other entry */
78 78 #define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ)
79 79
80 80 /*
81 81 * The following are defined for ace_t.
82 82 *
83 83 * Note, these are intentionally the same as the Windows
84 84 * "File Access Rights Constants" you can find on MSDN.
85 85 * (See also: "Standard Access Rights" on MSDN).
86 86 *
87 87 * The equivalent Windows names for these are just like
88 88 * those show below, with FILE_ in place of ACE_, except
89 89 * as noted below. Also note that Windows uses a special
90 90 * privilege: BYPASS_TRAVERSE_CHECKING, normally granted
91 91 * to everyone, that causes the absence of ACE_TRAVERSE
92 92 * to be ignored.
93 93 */
94 94 #define ACE_READ_DATA 0x00000001 /* file: read data */
95 95 #define ACE_LIST_DIRECTORY 0x00000001 /* dir: list files */
96 96 #define ACE_WRITE_DATA 0x00000002 /* file: write data */
97 97 #define ACE_ADD_FILE 0x00000002 /* dir: create file */
98 98 #define ACE_APPEND_DATA 0x00000004 /* file: append data */
99 99 #define ACE_ADD_SUBDIRECTORY 0x00000004 /* dir: create subdir */
100 100 #define ACE_READ_NAMED_ATTRS 0x00000008 /* FILE_READ_EA */
101 101 #define ACE_WRITE_NAMED_ATTRS 0x00000010 /* FILE_WRITE_EA */
102 102 #define ACE_EXECUTE 0x00000020 /* file: execute */
103 103 #define ACE_TRAVERSE 0x00000020 /* dir: lookup name */
104 104 #define ACE_DELETE_CHILD 0x00000040 /* dir: unlink child */
105 105 #define ACE_READ_ATTRIBUTES 0x00000080 /* (all) stat, etc. */
106 106 #define ACE_WRITE_ATTRIBUTES 0x00000100 /* (all) utimes, etc. */
107 107 #define ACE_DELETE 0x00010000 /* (all) unlink self */
108 108 #define ACE_READ_ACL 0x00020000 /* (all) getsecattr */
109 109 #define ACE_WRITE_ACL 0x00040000 /* (all) setsecattr */
110 110 #define ACE_WRITE_OWNER 0x00080000 /* (all) chown */
111 111 #define ACE_SYNCHRONIZE 0x00100000 /* (all) see MSDN */
112 112
113 113 /*
114 114 * Some of the following are the same as Windows uses. (but NOT ALL!)
115 115 * See the "ACE_HEADER" structure description on MSDN for details.
116 116 * Comments show relations to the MSDN names.
117 117 */
118 118 #define ACE_FILE_INHERIT_ACE 0x0001 /* = OBJECT_INHERIT_ACE */
119 119 #define ACE_DIRECTORY_INHERIT_ACE 0x0002 /* = CONTAINER_INHERIT_ACE */
120 120 #define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 /* = NO_PROPAGATE_INHERIT_ACE */
121 121 #define ACE_INHERIT_ONLY_ACE 0x0008 /* = INHERIT_ONLY_ACE */
122 122 #define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010
123 123 #define ACE_FAILED_ACCESS_ACE_FLAG 0x0020
124 124 #define ACE_IDENTIFIER_GROUP 0x0040
125 125 #define ACE_INHERITED_ACE 0x0080 /* INHERITED_ACE, 0x10 on NT */
126 126 #define ACE_OWNER 0x1000
127 127 #define ACE_GROUP 0x2000
128 128 #define ACE_EVERYONE 0x4000
129 129
130 130 /* These four are the same as Windows, but with an ACE_ prefix added. */
131 131 #define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000
132 132 #define ACE_ACCESS_DENIED_ACE_TYPE 0x0001
133 133 #define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002
134 134 #define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003
135 135
136 136 #define ACL_AUTO_INHERIT 0x0001
137 137 #define ACL_PROTECTED 0x0002
138 138 #define ACL_DEFAULTED 0x0004
139 139 #define ACL_FLAGS_ALL (ACL_AUTO_INHERIT|ACL_PROTECTED| \
140 140 ACL_DEFAULTED)
141 141
142 142 /*
143 143 * These are only applicable in a CIFS context.
144 144 * Here again, same as Windows, but with an ACE_ prefix added.
145 145 */
146 146 #define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04
147 147 #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
148 148 #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
149 149 #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
150 150 #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
151 151 #define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09
152 152 #define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A
153 153 #define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B
154 154 #define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C
155 155 #define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D
156 156 #define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E
157 157 #define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F
158 158 #define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10
159 159
160 160 #define ACE_ALL_TYPES 0x001F
161 161
162 162 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
163 163
164 164 typedef struct ace_object {
165 165 uid_t a_who; /* uid or gid */
166 166 uint32_t a_access_mask; /* read,write,... */
167 167 uint16_t a_flags; /* see below */
168 168 uint16_t a_type; /* allow or deny */
169 169 uint8_t a_obj_type[16]; /* obj type */
170 170 uint8_t a_inherit_obj_type[16]; /* inherit obj */
171 171 } ace_object_t;
172 172
173 173 #endif
174 174
175 175 #define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
176 176 ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
177 177 ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
178 178 ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
179 179 ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
180 180
181 181 #define ACE_ALL_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA| \
182 182 ACE_WRITE_ATTRIBUTES|ACE_WRITE_NAMED_ATTRS|ACE_WRITE_ACL| \
183 183 ACE_WRITE_OWNER|ACE_DELETE|ACE_DELETE_CHILD)
184 184
185 185 #define ACE_READ_PERMS (ACE_READ_DATA|ACE_READ_ACL|ACE_READ_ATTRIBUTES| \
186 186 ACE_READ_NAMED_ATTRS)
187 187
188 188 #define ACE_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA|ACE_WRITE_ATTRIBUTES| \
189 189 ACE_WRITE_NAMED_ATTRS)
190 190
191 191 #define ACE_MODIFY_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
192 192 ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
193 193 ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
194 194 ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_SYNCHRONIZE)
195 195 /*
196 196 * The following flags are supported by both NFSv4 ACLs and ace_t.
197 197 */
198 198 #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \
199 199 ACE_DIRECTORY_INHERIT_ACE | \
200 200 ACE_NO_PROPAGATE_INHERIT_ACE | \
201 201 ACE_INHERIT_ONLY_ACE | \
202 202 ACE_IDENTIFIER_GROUP)
203 203
204 204 #define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \
205 205 ACE_IDENTIFIER_GROUP)
206 206 #define ACE_INHERIT_FLAGS (ACE_FILE_INHERIT_ACE| \
207 207 ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE)
208 208
209 209 /* cmd args to acl(2) for aclent_t */
210 210 #define GETACL 1
211 211 #define SETACL 2
212 212 #define GETACLCNT 3
213 213
214 214 /* cmd's to manipulate ace acls. */
215 215 #define ACE_GETACL 4
216 216 #define ACE_SETACL 5
217 217 #define ACE_GETACLCNT 6
218 218
219 219 /* minimal acl entries from GETACLCNT */
220 220 #define MIN_ACL_ENTRIES 4
221 221
222 222 #if !defined(_KERNEL)
223 223
224 224 /* acl check errors */
225 225 #define GRP_ERROR 1
226 226 #define USER_ERROR 2
227 227 #define OTHER_ERROR 3
228 228 #define CLASS_ERROR 4
229 229 #define DUPLICATE_ERROR 5
230 230 #define MISS_ERROR 6
231 231 #define MEM_ERROR 7
232 232 #define ENTRY_ERROR 8
233 233
234 234
235 235 /*
236 236 * similar to ufs_acl.h: changed to char type for user commands (tar, cpio)
237 237 * Attribute types
238 238 */
239 239 #define UFSD_FREE ('0') /* Free entry */
240 240 #define UFSD_ACL ('1') /* Access Control Lists */
241 241 #define UFSD_DFACL ('2') /* reserved for future use */
242 242 #define ACE_ACL ('3') /* ace_t style acls */
243 243
244 244 /*
|
↓ open down ↓ |
207 lines elided |
↑ open up ↑ |
245 245 * flag to [f]acl_get()
246 246 * controls whether a trivial acl should be returned.
247 247 */
248 248 #define ACL_NO_TRIVIAL 0x2
249 249
250 250
251 251 /*
252 252 * Flags to control acl_totext()
253 253 */
254 254
255 -#define ACL_APPEND_ID 0x1 /* append uid/gid to user/group entries */
256 -#define ACL_COMPACT_FMT 0x2 /* build ACL in ls -V format */
257 -#define ACL_NORESOLVE 0x4 /* don't do name service lookups */
258 -#define ACL_SID_FMT 0x8 /* use usersid/groupsid when appropriate */
255 +#define ACL_APPEND_ID 0x01 /* append uid/gid to user/group entries */
256 +#define ACL_COMPACT_FMT 0x02 /* build ACL in ls -V format */
257 +#define ACL_NORESOLVE 0x04 /* don't do name service lookups */
258 +#define ACL_SID_FMT 0x08 /* use usersid/groupsid when appropriate */
259 +#define ACL_EPHEMERAL 0x10 /* Print raw ephemeral id */
259 260
260 261 /*
261 262 * Legacy aclcheck errors for aclent_t ACLs
262 263 */
263 264 #define EACL_GRP_ERROR GRP_ERROR
264 265 #define EACL_USER_ERROR USER_ERROR
265 266 #define EACL_OTHER_ERROR OTHER_ERROR
266 267 #define EACL_CLASS_ERROR CLASS_ERROR
267 268 #define EACL_DUPLICATE_ERROR DUPLICATE_ERROR
268 269 #define EACL_MISS_ERROR MISS_ERROR
269 270 #define EACL_MEM_ERROR MEM_ERROR
270 271 #define EACL_ENTRY_ERROR ENTRY_ERROR
271 272
272 273 #define EACL_INHERIT_ERROR 9 /* invalid inherit flags */
273 274 #define EACL_FLAGS_ERROR 10 /* unknown flag value */
274 275 #define EACL_PERM_MASK_ERROR 11 /* unknown permission */
275 276 #define EACL_COUNT_ERROR 12 /* invalid acl count */
276 277
277 278 #define EACL_INVALID_SLOT 13 /* invalid acl slot */
278 279 #define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */
279 280 #define EACL_DIFF_TYPE 15 /* acls aren't same type */
280 281
281 282 #define EACL_INVALID_USER_GROUP 16 /* need user/group name */
282 283 #define EACL_INVALID_STR 17 /* invalid acl string */
283 284 #define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */
284 285 #define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */
285 286 #define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */
286 287 #define EACL_MISSING_FIELDS 21 /* missing fields in acl */
287 288
288 289 #define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */
289 290
290 291 extern int aclcheck(aclent_t *, int, int *);
291 292 extern int acltomode(aclent_t *, int, mode_t *);
292 293 extern int aclfrommode(aclent_t *, int, mode_t *);
293 294 extern int aclsort(int, int, aclent_t *);
294 295 extern char *acltotext(aclent_t *, int);
295 296 extern aclent_t *aclfromtext(char *, int *);
296 297 extern void acl_free(acl_t *);
297 298 extern int acl_get(const char *, int, acl_t **);
298 299 extern int facl_get(int, int, acl_t **);
299 300 extern int acl_set(const char *, acl_t *acl);
300 301 extern int facl_set(int, acl_t *acl);
301 302 extern int acl_strip(const char *, uid_t, gid_t, mode_t);
302 303 extern int acl_trivial(const char *);
303 304 extern char *acl_totext(acl_t *, int);
304 305 extern int acl_fromtext(const char *, acl_t **);
305 306 extern int acl_check(acl_t *, int);
306 307
307 308 #else /* !defined(_KERNEL) */
308 309
309 310 extern void ksort(caddr_t, int, int, int (*)(void *, void *));
310 311 extern int cmp2acls(void *, void *);
311 312
312 313 #endif /* !defined(_KERNEL) */
313 314
314 315 extern int acl(const char *path, int cmd, int cnt, void *buf);
315 316 extern int facl(int fd, int cmd, int cnt, void *buf);
316 317
317 318 #ifdef __cplusplus
318 319 }
319 320 #endif
320 321
321 322 #endif /* _SYS_ACL_H */
|
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX