]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/compat/opensolaris/sys/acl.h
This commit was generated by cvs2svn to compensate for changes in r171364,
[FreeBSD/FreeBSD.git] / sys / compat / opensolaris / sys / acl.h
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _OPENSOLARIS_SYS_ACL_H_
27 #define _OPENSOLARIS_SYS_ACL_H_
28
29 #include_next <sys/acl.h>
30
31 #define MAX_ACL_ENTRIES         (1024)  /* max entries of each type */
32
33 typedef struct acl_entry        aclent_t;
34 #define a_type  ae_tag
35 #define a_id    ae_id
36 #define a_perm  ae_perm
37
38 typedef struct ace {
39         uid_t           a_who;          /* uid or gid */
40         uint32_t        a_access_mask;  /* read,write,... */
41         uint16_t        a_flags;        /* see below */
42         uint16_t        a_type;         /* allow or deny */
43 } ace_t;
44
45 #if 0
46 /*
47  * The following are Defined types for an aclent_t.
48  */
49 #define USER_OBJ        (0x01)          /* object owner */
50 #define USER            (0x02)          /* additional users */
51 #define GROUP_OBJ       (0x04)          /* owning group of the object */
52 #define GROUP           (0x08)          /* additional groups */
53 #define CLASS_OBJ       (0x10)          /* file group class and mask entry */
54 #define OTHER_OBJ       (0x20)          /* other entry for the object */
55 #define ACL_DEFAULT     (0x1000)        /* default flag */
56 /* default object owner */
57 #define DEF_USER_OBJ    (ACL_DEFAULT | USER_OBJ)
58 /* defalut additional users */
59 #define DEF_USER        (ACL_DEFAULT | USER)
60 /* default owning group */
61 #define DEF_GROUP_OBJ   (ACL_DEFAULT | GROUP_OBJ)
62 /* default additional groups */
63 #define DEF_GROUP       (ACL_DEFAULT | GROUP)
64 /* default mask entry */
65 #define DEF_CLASS_OBJ   (ACL_DEFAULT | CLASS_OBJ)
66 /* default other entry */
67 #define DEF_OTHER_OBJ   (ACL_DEFAULT | OTHER_OBJ)
68 #endif
69
70 /*
71  * The following are defined for ace_t.
72  */
73 #define ACE_READ_DATA           0x00000001
74 #define ACE_LIST_DIRECTORY      0x00000001
75 #define ACE_WRITE_DATA          0x00000002
76 #define ACE_ADD_FILE            0x00000002
77 #define ACE_APPEND_DATA         0x00000004
78 #define ACE_ADD_SUBDIRECTORY    0x00000004
79 #define ACE_READ_NAMED_ATTRS    0x00000008
80 #define ACE_WRITE_NAMED_ATTRS   0x00000010
81 #define ACE_EXECUTE             0x00000020
82 #define ACE_DELETE_CHILD        0x00000040
83 #define ACE_READ_ATTRIBUTES     0x00000080
84 #define ACE_WRITE_ATTRIBUTES    0x00000100
85 #define ACE_DELETE              0x00010000
86 #define ACE_READ_ACL            0x00020000
87 #define ACE_WRITE_ACL           0x00040000
88 #define ACE_WRITE_OWNER         0x00080000
89 #define ACE_SYNCHRONIZE         0x00100000
90
91 #define ACE_FILE_INHERIT_ACE            0x0001
92 #define ACE_DIRECTORY_INHERIT_ACE       0x0002
93 #define ACE_NO_PROPAGATE_INHERIT_ACE    0x0004
94 #define ACE_INHERIT_ONLY_ACE            0x0008
95 #define ACE_SUCCESSFUL_ACCESS_ACE_FLAG  0x0010
96 #define ACE_FAILED_ACCESS_ACE_FLAG      0x0020
97 #define ACE_IDENTIFIER_GROUP            0x0040
98 #define ACE_OWNER                       0x1000
99 #define ACE_GROUP                       0x2000
100 #define ACE_EVERYONE                    0x4000
101
102 #define ACE_ACCESS_ALLOWED_ACE_TYPE     0x0000
103 #define ACE_ACCESS_DENIED_ACE_TYPE      0x0001
104 #define ACE_SYSTEM_AUDIT_ACE_TYPE       0x0002
105 #define ACE_SYSTEM_ALARM_ACE_TYPE       0x0003
106
107 #define ACE_ALL_PERMS   (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
108     ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
109     ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
110     ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
111     ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
112
113 /*
114  * The following flags are supported by both NFSv4 ACLs and ace_t.
115  */
116 #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \
117     ACE_DIRECTORY_INHERIT_ACE | \
118     ACE_NO_PROPAGATE_INHERIT_ACE | \
119     ACE_INHERIT_ONLY_ACE | \
120     ACE_IDENTIFIER_GROUP)
121
122 #define ACE_TYPE_FLAGS  (ACE_OWNER|ACE_GROUP|ACE_EVERYONE|ACE_IDENTIFIER_GROUP)
123
124 #if 0
125 /* cmd args to acl(2) for aclent_t  */
126 #define GETACL                  1
127 #define SETACL                  2
128 #define GETACLCNT               3
129 #endif
130
131 /* cmd's to manipulate ace acls. */
132 #define ACE_GETACL              4
133 #define ACE_SETACL              5
134 #define ACE_GETACLCNT           6
135
136 #if 0
137 /* minimal acl entries from GETACLCNT */
138 #define MIN_ACL_ENTRIES         4
139
140 #if !defined(_KERNEL)
141
142 /* acl check errors */
143 #define GRP_ERROR               1
144 #define USER_ERROR              2
145 #define OTHER_ERROR             3
146 #define CLASS_ERROR             4
147 #define DUPLICATE_ERROR         5
148 #define MISS_ERROR              6
149 #define MEM_ERROR               7
150 #define ENTRY_ERROR             8
151
152
153 /*
154  * similar to ufs_acl.h: changed to char type for user commands (tar, cpio)
155  * Attribute types
156  */
157 #define UFSD_FREE       ('0')   /* Free entry */
158 #define UFSD_ACL        ('1')   /* Access Control Lists */
159 #define UFSD_DFACL      ('2')   /* reserved for future use */
160 #define ACE_ACL         ('3')   /* ace_t style acls */
161
162 /*
163  * flag to [f]acl_get()
164  * controls whether a trivial acl should be returned.
165  */
166 #define ACL_NO_TRIVIAL  0x2
167
168
169 /*
170  * Flags to control acl_totext()
171  */
172
173 #define ACL_APPEND_ID   0x1     /* append uid/gid to user/group entries */
174 #define ACL_COMPACT_FMT 0x2     /* build ACL in ls -V format */
175 #define ACL_NORESOLVE   0x4     /* don't do name service lookups */
176
177 /*
178  * Legacy aclcheck errors for aclent_t ACLs
179  */
180 #define EACL_GRP_ERROR          GRP_ERROR
181 #define EACL_USER_ERROR         USER_ERROR
182 #define EACL_OTHER_ERROR        OTHER_ERROR
183 #define EACL_CLASS_ERROR        CLASS_ERROR
184 #define EACL_DUPLICATE_ERROR    DUPLICATE_ERROR
185 #define EACL_MISS_ERROR         MISS_ERROR
186 #define EACL_MEM_ERROR          MEM_ERROR
187 #define EACL_ENTRY_ERROR        ENTRY_ERROR
188
189 #define EACL_INHERIT_ERROR      9               /* invalid inherit flags */
190 #define EACL_FLAGS_ERROR        10              /* unknown flag value */
191 #define EACL_PERM_MASK_ERROR    11              /* unknown permission */
192 #define EACL_COUNT_ERROR        12              /* invalid acl count */
193
194 #define EACL_INVALID_SLOT       13              /* invalid acl slot */
195 #define EACL_NO_ACL_ENTRY       14              /* Entry doesn't exist */
196 #define EACL_DIFF_TYPE          15              /* acls aren't same type */
197
198 #define EACL_INVALID_USER_GROUP 16              /* need user/group name */
199 #define EACL_INVALID_STR        17              /* invalid acl string */
200 #define EACL_FIELD_NOT_BLANK    18              /* can't have blank field */
201 #define EACL_INVALID_ACCESS_TYPE 19             /* invalid access type */
202 #define EACL_UNKNOWN_DATA       20              /* Unrecognized data in ACL */
203 #define EACL_MISSING_FIELDS     21              /* missing fields in acl */
204
205 #define EACL_INHERIT_NOTDIR     22              /* Need dir for inheritance */
206
207 extern int aclcheck(aclent_t *, int, int *);
208 extern int acltomode(aclent_t *, int, mode_t *);
209 extern int aclfrommode(aclent_t *, int, mode_t *);
210 extern int aclsort(int, int, aclent_t *);
211 extern char *acltotext(aclent_t *, int);
212 extern aclent_t *aclfromtext(char *, int *);
213 extern void acl_free(acl_t *);
214 extern int acl_get(const char *, int, acl_t **);
215 extern int facl_get(int, int, acl_t **);
216 extern int acl_set(const char *, acl_t *acl);
217 extern int facl_set(int, acl_t *acl);
218 extern int acl_strip(const char *, uid_t, gid_t, mode_t);
219 extern int acl_trivial(const char *);
220 extern char *acl_totext(acl_t *, int);
221 extern int acl_fromtext(const char *, acl_t **);
222 extern int acl_check(acl_t *, int);
223
224 #else   /* !defined(_KERNEL) */
225
226 extern void ksort(caddr_t, int, int, int (*)(void *, void *));
227 extern int cmp2acls(void *, void *);
228
229 #endif  /* !defined(_KERNEL) */
230
231 #if defined(__STDC__)
232 extern int acl(const char *path, int cmd, int cnt, void *buf);
233 extern int facl(int fd, int cmd, int cnt, void *buf);
234 #else   /* !__STDC__ */
235 extern int acl();
236 extern int facl();
237 #endif  /* defined(__STDC__) */
238
239 #endif
240
241 #endif /* _OPENSOLARIS_SYS_ACL_H */