]> git.saurik.com Git - apple/libc.git/blob - include/sys/acl.h
Libc-391.4.1.tar.gz
[apple/libc.git] / include / sys / acl.h
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #ifndef _SYS_ACL_H
24 #define _SYS_ACL_H
25
26 #include <sys/kauth.h>
27
28 /*
29 * Implementation constants.
30 *
31 * The ACL_TYPE_EXTENDED binary format permits 169 entries plus
32 * the ACL header in a page. Give ourselves some room to grow;
33 * this limit is arbitrary.
34 */
35 #define ACL_MAX_ENTRIES 128
36
37 /* 23.2.2 Individual object access permissions - nonstandard */
38 typedef enum {
39 ACL_READ_DATA = KAUTH_VNODE_READ_DATA,
40 ACL_LIST_DIRECTORY = KAUTH_VNODE_LIST_DIRECTORY,
41 ACL_WRITE_DATA = KAUTH_VNODE_WRITE_DATA,
42 ACL_ADD_FILE = KAUTH_VNODE_ADD_FILE,
43 ACL_EXECUTE = KAUTH_VNODE_EXECUTE,
44 ACL_SEARCH = KAUTH_VNODE_SEARCH,
45 ACL_DELETE = KAUTH_VNODE_DELETE,
46 ACL_APPEND_DATA = KAUTH_VNODE_APPEND_DATA,
47 ACL_ADD_SUBDIRECTORY = KAUTH_VNODE_ADD_SUBDIRECTORY,
48 ACL_DELETE_CHILD = KAUTH_VNODE_DELETE_CHILD,
49 ACL_READ_ATTRIBUTES = KAUTH_VNODE_READ_ATTRIBUTES,
50 ACL_WRITE_ATTRIBUTES = KAUTH_VNODE_WRITE_ATTRIBUTES,
51 ACL_READ_EXTATTRIBUTES = KAUTH_VNODE_READ_EXTATTRIBUTES,
52 ACL_WRITE_EXTATTRIBUTES = KAUTH_VNODE_WRITE_EXTATTRIBUTES,
53 ACL_READ_SECURITY = KAUTH_VNODE_READ_SECURITY,
54 ACL_WRITE_SECURITY = KAUTH_VNODE_WRITE_SECURITY,
55 ACL_CHANGE_OWNER = KAUTH_VNODE_CHANGE_OWNER
56 } acl_perm_t;
57
58 /* 23.2.5 ACL entry tag type bits - nonstandard */
59 typedef enum {
60 ACL_UNDEFINED_TAG = 0,
61 ACL_EXTENDED_ALLOW = KAUTH_ACE_PERMIT,
62 ACL_EXTENDED_DENY = KAUTH_ACE_DENY
63 } acl_tag_t;
64
65 /* 23.2.6 Individual ACL types */
66 typedef enum {
67 ACL_TYPE_EXTENDED = 0x00000100,
68 /* Posix 1003.1e types - not supported */
69 ACL_TYPE_ACCESS = 0x00000000,
70 ACL_TYPE_DEFAULT = 0x00000001,
71 /* The following types are defined on FreeBSD/Linux - not supported */
72 ACL_TYPE_AFS = 0x00000002,
73 ACL_TYPE_CODA = 0x00000003,
74 ACL_TYPE_NTFS = 0x00000004,
75 ACL_TYPE_NWFS = 0x00000005
76 } acl_type_t;
77
78 /* 23.2.7 ACL qualifier constants */
79
80 #define ACL_UNDEFINED_ID NULL /* XXX ? */
81
82 /* 23.2.8 ACL Entry Constants */
83 typedef enum {
84 ACL_FIRST_ENTRY = 0,
85 ACL_NEXT_ENTRY = -1,
86 ACL_LAST_ENTRY = -2
87 } acl_entry_id_t;
88
89 /* nonstandard ACL / entry flags */
90 typedef enum {
91 ACL_FLAG_DEFER_INHERIT = (1 << 0), /* tentative */
92 ACL_ENTRY_INHERITED = KAUTH_ACE_INHERITED,
93 ACL_ENTRY_FILE_INHERIT = KAUTH_ACE_FILE_INHERIT,
94 ACL_ENTRY_DIRECTORY_INHERIT = KAUTH_ACE_DIRECTORY_INHERIT,
95 ACL_ENTRY_LIMIT_INHERIT = KAUTH_ACE_LIMIT_INHERIT,
96 ACL_ENTRY_ONLY_INHERIT = KAUTH_ACE_ONLY_INHERIT
97 } acl_flag_t;
98
99 /* "External" ACL types */
100
101 struct _acl;
102 struct _acl_entry;
103 struct _acl_permset;
104 struct _acl_flagset;
105
106 typedef struct _acl *acl_t;
107 typedef struct _acl_entry *acl_entry_t;
108 typedef struct _acl_permset *acl_permset_t;
109 typedef struct _acl_flagset *acl_flagset_t;
110
111 __BEGIN_DECLS
112 /* 23.1.6.1 ACL Storage Management */
113 extern acl_t acl_dup(acl_t acl);
114 extern int acl_free(void *obj_p);
115 extern acl_t acl_init(int count);
116
117 /* 23.1.6.2 (1) ACL Entry manipulation */
118 extern int acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d);
119 extern int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p);
120 extern int acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int entry_index);
121 extern int acl_delete_entry(acl_t acl, acl_entry_t entry_d);
122 extern int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p);
123 extern int acl_valid(acl_t acl);
124 extern int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl);
125 extern int acl_valid_file_np(const char *path, acl_type_t type, acl_t acl);
126 extern int acl_valid_link_np(const char *path, acl_type_t type, acl_t acl);
127
128 /* 23.1.6.2 (2) Manipulate permissions within an ACL entry */
129 extern int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm);
130 extern int acl_calc_mask(acl_t *acl_p); /* not supported */
131 extern int acl_clear_perms(acl_permset_t permset_d);
132 extern int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm);
133 extern int acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm);
134 extern int acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p);
135 extern int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d);
136
137 /* nonstandard - manipulate flags on ACLs and entries */
138 extern int acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
139 extern int acl_clear_flags_np(acl_flagset_t flagset_d);
140 extern int acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
141 extern int acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag);
142 extern int acl_get_flagset_np(void *obj_p, acl_flagset_t *flagset_p);
143 extern int acl_set_flagset_np(void *obj_p, acl_flagset_t flagset_d);
144
145 /* 23.1.6.2 (3) Manipulate ACL entry tag type and qualifier */
146 extern void *acl_get_qualifier(acl_entry_t entry_d);
147 extern int acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p);
148 extern int acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p);
149 extern int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type);
150
151 /* 23.1.6.3 ACL manipulation on an Object */
152 extern int acl_delete_def_file(const char *path_p); /* not supported */
153 extern acl_t acl_get_fd(int fd);
154 extern acl_t acl_get_fd_np(int fd, acl_type_t type);
155 extern acl_t acl_get_file(const char *path_p, acl_type_t type);
156 extern acl_t acl_get_link_np(const char *path_p, acl_type_t type);
157 extern int acl_set_fd(int fd, acl_t acl);
158 extern int acl_set_fd_np(int fd, acl_t acl, acl_type_t acl_type);
159 extern int acl_set_file(const char *path_p, acl_type_t type, acl_t acl);
160 extern int acl_set_link(const char *path_p, acl_type_t type, acl_t acl);
161
162 /* 23.1.6.4 ACL Format translation */
163 extern ssize_t acl_copy_ext(void *buf_p, acl_t acl, ssize_t size);
164 extern ssize_t acl_copy_ext_native(void *buf_p, acl_t acl, ssize_t size);
165 extern acl_t acl_copy_int(const void *buf_p);
166 extern acl_t acl_copy_int_native(const void *buf_p);
167 extern acl_t acl_from_text(const char *buf_p);
168 extern ssize_t acl_size(acl_t acl);
169 extern char *acl_to_text(acl_t acl, ssize_t *len_p);
170 __END_DECLS
171
172 #endif /* _SYS_ACL_H */