]>
git.saurik.com Git - apple/libc.git/blob - posix1e/acl_perm.c
2 * Copyright (c) 2004-2010 Apple, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #include <sys/appleapiopts.h>
25 #include <sys/types.h>
33 #if __DARWIN_ACL_READ_DATA != KAUTH_VNODE_READ_DATA
34 # error __DARWIN_ACL_READ_DATA != KAUTH_VNODE_READ_DATA
36 #if __DARWIN_ACL_LIST_DIRECTORY != KAUTH_VNODE_LIST_DIRECTORY
37 # error __DARWIN_ACL_LIST_DIRECTORY != KAUTH_VNODE_LIST_DIRECTORY
39 #if __DARWIN_ACL_WRITE_DATA != KAUTH_VNODE_WRITE_DATA
40 # error __DARWIN_ACL_WRITE_DATA != KAUTH_VNODE_WRITE_DATA
42 #if __DARWIN_ACL_ADD_FILE != KAUTH_VNODE_ADD_FILE
43 # error __DARWIN_ACL_ADD_FILE != KAUTH_VNODE_ADD_FILE
45 #if __DARWIN_ACL_EXECUTE != KAUTH_VNODE_EXECUTE
46 # error __DARWIN_ACL_EXECUTE != KAUTH_VNODE_EXECUTE
48 #if __DARWIN_ACL_SEARCH != KAUTH_VNODE_SEARCH
49 # error __DARWIN_ACL_SEARCH != KAUTH_VNODE_SEARCH
51 #if __DARWIN_ACL_DELETE != KAUTH_VNODE_DELETE
52 # error __DARWIN_ACL_DELETE != KAUTH_VNODE_DELETE
54 #if __DARWIN_ACL_APPEND_DATA != KAUTH_VNODE_APPEND_DATA
55 # error __DARWIN_ACL_APPEND_DATA != KAUTH_VNODE_APPEND_DATA
57 #if __DARWIN_ACL_ADD_SUBDIRECTORY != KAUTH_VNODE_ADD_SUBDIRECTORY
58 # error __DARWIN_ACL_ADD_SUBDIRECTORY != KAUTH_VNODE_ADD_SUBDIRECTORY
60 #if __DARWIN_ACL_DELETE_CHILD != KAUTH_VNODE_DELETE_CHILD
61 # error __DARWIN_ACL_DELETE_CHILD != KAUTH_VNODE_DELETE_CHILD
63 #if __DARWIN_ACL_READ_ATTRIBUTES != KAUTH_VNODE_READ_ATTRIBUTES
64 # error __DARWIN_ACL_READ_ATTRIBUTES != KAUTH_VNODE_READ_ATTRIBUTES
66 #if __DARWIN_ACL_WRITE_ATTRIBUTES != KAUTH_VNODE_WRITE_ATTRIBUTES
67 # error __DARWIN_ACL_WRITE_ATTRIBUTES != KAUTH_VNODE_WRITE_ATTRIBUTES
69 #if __DARWIN_ACL_READ_EXTATTRIBUTES != KAUTH_VNODE_READ_EXTATTRIBUTES
70 # error __DARWIN_ACL_READ_EXTATTRIBUTES != KAUTH_VNODE_READ_EXTATTRIBUTES
72 #if __DARWIN_ACL_WRITE_EXTATTRIBUTES != KAUTH_VNODE_WRITE_EXTATTRIBUTES
73 # error __DARWIN_ACL_WRITE_EXTATTRIBUTES != KAUTH_VNODE_WRITE_EXTATTRIBUTES
75 #if __DARWIN_ACL_READ_SECURITY != KAUTH_VNODE_READ_SECURITY
76 # error __DARWIN_ACL_READ_SECURITY != KAUTH_VNODE_READ_SECURITY
78 #if __DARWIN_ACL_WRITE_SECURITY != KAUTH_VNODE_WRITE_SECURITY
79 # error __DARWIN_ACL_WRITE_SECURITY != KAUTH_VNODE_WRITE_SECURITY
81 #if __DARWIN_ACL_CHANGE_OWNER != KAUTH_VNODE_CHANGE_OWNER
82 # error __DARWIN_ACL_CHANGE_OWNER != KAUTH_VNODE_CHANGE_OWNER
84 #if __DARWIN_ACL_SYNCHRONIZE != KAUTH_VNODE_SYNCHRONIZE
85 # error __DARWIN_ACL_SYNCHRONIZE != KAUTH_VNODE_SYNCHRONIZE
89 acl_add_perm(acl_permset_t permset
, acl_perm_t perm
)
91 /* XXX validate perms */
92 _ACL_VALIDATE_PERM(perm
);
94 permset
->ap_perms
|= perm
;
99 acl_clear_perms(acl_permset_t permset
)
101 /* XXX validate perms */
103 permset
->ap_perms
= 0;
108 acl_delete_perm(acl_permset_t permset
, acl_perm_t perm
)
110 /* XXX validate perms */
111 _ACL_VALIDATE_PERM(perm
);
113 permset
->ap_perms
&= ~perm
;
118 acl_get_perm_np(acl_permset_t permset
, acl_perm_t perm
)
120 _ACL_VALIDATE_PERM(perm
);
122 return((perm
& permset
->ap_perms
) ? 1 : 0);
126 acl_get_permset(acl_entry_t entry
, acl_permset_t
*permset_p
)
128 _ACL_VALIDATE_ENTRY(entry
);
130 *permset_p
= (acl_permset_t
)&entry
->ae_perms
;
135 acl_set_permset(acl_entry_t entry
, acl_permset_t permset
)
137 _ACL_VALIDATE_ENTRY(entry
);
139 entry
->ae_perms
= permset
->ap_perms
;
144 acl_maximal_permset_mask_np(acl_permset_mask_t
* mask_p
)
146 /* Bitwise or of all possible acl_perm_t values */
147 *mask_p
= _ACL_PERMS_MASK
;
152 acl_get_permset_mask_np(acl_entry_t entry
, acl_permset_mask_t
* mask_p
)
154 _ACL_VALIDATE_ENTRY(entry
);
156 *mask_p
= (acl_permset_mask_t
)entry
->ae_perms
;
161 acl_set_permset_mask_np(acl_entry_t entry
, acl_permset_mask_t mask
)
163 _ACL_VALIDATE_ENTRY(entry
);
164 _ACL_VALIDATE_PERM(mask
);
166 entry
->ae_perms
= mask
;