]>
git.saurik.com Git - apple/libc.git/blob - posix1e/aclvar.h
2 * Copyright (c) 2004, 2008, 2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/kauth.h>
29 * Internal access control list entry representation.
33 #define _ACL_ENTRY_MAGIC 0xac1ac101
41 * Internal representation of an ACL.
42 * XXX static allocation is wasteful.
46 #define _ACL_ACL_MAGIC 0xac1ac102
50 struct _acl_entry a_ace
[ACL_MAX_ENTRIES
];
61 * ACL entry permissions.
68 * Argument validation.
71 * Because of the use of special values for structure pointer (like
72 * _FILESEC_REMOVE_ACL), dereferences causes crashes. Rather than try to
73 * enumerate all such special values, we will assume there are a small
74 * number of these values, centered about zero, so we can just check the
75 * values are in this range. We have to do the check for both ACLs and
76 * ACEs, because the API uses the same routines on ACLs and ACEs.
79 #define _ACL_SPECIAL_RANGE 16
81 #define _ACL_VALID_ENTRY(_e) ((((intptr_t)(_e)) > _ACL_SPECIAL_RANGE || ((intptr_t)(_e)) < -(_ACL_SPECIAL_RANGE)) && (_e)->ae_magic == _ACL_ENTRY_MAGIC)
83 #define _ACL_VALID_ACL(_a) ((((intptr_t)(_a)) > _ACL_SPECIAL_RANGE || ((intptr_t)(_a)) < -(_ACL_SPECIAL_RANGE)) && (_a)->a_magic == _ACL_ACL_MAGIC)
85 #define _ACL_ENTRY_CONTAINED(_a, _e) \
86 ((_e) >= &(_a)->a_ace[0]) && ((_e) < &(_a)->a_ace[ACL_MAX_ENTRIES])
88 #define _ACL_VALID_FLAG(_f) (((_f) & _ACL_FLAGS_MASK) == (_f))
90 #define _ACL_VALID_ENTRY_FLAG(_f) (((_f) & _ACL_ENTRY_FLAGS_MASK) == (_f))
92 #define _ACL_PERMS_MASK (ACL_READ_DATA | \
93 ACL_LIST_DIRECTORY | \
100 ACL_ADD_SUBDIRECTORY | \
102 ACL_READ_ATTRIBUTES | \
103 ACL_WRITE_ATTRIBUTES | \
104 ACL_READ_EXTATTRIBUTES | \
105 ACL_WRITE_EXTATTRIBUTES | \
106 ACL_READ_SECURITY | \
107 ACL_WRITE_SECURITY | \
111 #define _ACL_VALID_PERM(_f) (((_f) & ~_ACL_PERMS_MASK) == 0)
113 #define _ACL_VALIDATE_ACL(_a) \
115 if (!_ACL_VALID_ACL((_a))) { \
121 #define _ACL_VALIDATE_ENTRY(_e) \
123 if (!_ACL_VALID_ENTRY((_e))) { \
129 #define _ACL_VALIDATE_ENTRY_CONTAINED(_a, _e) \
131 if (!_ACL_ENTRY_CONTAINED((_a), (_e))) { \
137 #define _ACL_VALIDATE_FLAG(_f) \
139 if (!_ACL_VALID_FLAG((_f))) { \
145 #define _ACL_VALIDATE_ENTRY_FLAG(_f) \
147 if (!_ACL_VALID_ENTRY_FLAG((_f))) { \
153 #define _ACL_VALIDATE_PERM(_f) \
155 if (!_ACL_VALID_PERM((_f))) { \
161 #endif /* _ACLVAR_H */