xref: /titanic_51/usr/src/lib/libsec/common/aclutils.h (revision 853389e344087efe23a5cc688693e5301a1cb90d)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _ACLUTILS_H
27 #define	_ACLUTILS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/acl.h>
33 #include <strings.h>
34 #include <locale.h>
35 #include <ctype.h>
36 #include <grp.h>
37 #include <pwd.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #define	ACL_REMOVE_ALL		0x0
44 #define	ACL_REMOVE_FIRST	0x1
45 
46 /*
47  * Hint for whether acl_totext() should use
48  * mnemonics:
49  * read_data/list_directory
50  * write_data/add_file or
51  * append_data/add_subdirectory
52  * when object of ACL is known.
53  */
54 
55 #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
56 #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
57 #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
58 
59 struct acl_perm_type {
60 	int		perm_style;	/* type of perm style, see above */
61 	char		*perm_str;	/* string value being returned */
62 	uint32_t	perm_val;	/* numeric value being returned */
63 };
64 
65 /*
66  * Textual representation of ace_t's access mask
67  */
68 #define	READ_DATA_TXT	"read_data/"
69 #define	WRITE_DATA_TXT	"write_data/"
70 #define	EXECUTE_TXT	"execute/"
71 #define	READ_XATTR_TXT	"read_xattr/"
72 #define	WRITE_XATTR_TXT	"write_xattr/"
73 #define	READ_ATTRIBUTES_TXT "read_attributes/"
74 #define	WRITE_ATTRIBUTES_TXT "write_attributes/"
75 #define	DELETE_TXT	"delete/"
76 #define	DELETE_CHILD_TXT "delete_child/"
77 #define	WRITE_OWNER_TXT "write_owner/"
78 #define	READ_ACL_TXT	"read_acl/"
79 #define	WRITE_ACL_TXT	"write_acl/"
80 #define	APPEND_DATA_TXT "append_data/"
81 #define	READ_DIR_TXT	"list_directory/read_data/"
82 #define	ADD_DIR_TXT	"add_subdirectory/append_data/"
83 #define	ADD_FILE_TXT	"add_file/write_data/"
84 #define	SYNCHRONIZE_TXT "synchronize"	/* not slash on this one */
85 
86 /*
87  * ace_t's flags
88  */
89 #define	OWNERAT_TXT	"owner@"
90 #define	GROUPAT_TXT	"group@"
91 #define	EVERYONEAT_TXT	"everyone@"
92 #define	GROUP_TXT	"group:"
93 #define	USER_TXT	"user:"
94 
95 /*
96  * ace_t's access types
97  */
98 #define	ALLOW_TXT	"allow"
99 #define	DENY_TXT	"deny"
100 #define	ALARM_TXT	"alarm"
101 #define	AUDIT_TXT	"audit"
102 #define	UNKNOWN_TXT	"unknown"
103 
104 extern char *yybuf;
105 extern acl_t *yyacl;
106 
107 extern int yyerror(const char *);
108 extern int get_id(int entry_type, char *name, int *id);
109 extern int ace_entry_type(int entry_type);
110 extern int aclent_entry_type(int type, int owning, int *ret);
111 extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
112 extern int compute_aclent_perms(char *str, o_mode_t *mask);
113 extern int compute_ace_inherit(char *str, uint32_t *imask);
114 extern int acl_addentries(acl_t *, acl_t *, int);
115 extern int acl_removeentries(acl_t *, acl_t *, int, int);
116 extern int acl_modifyentries(acl_t *, acl_t *, int);
117 extern void acl_printacl(acl_t *, int, int);
118 extern char *acl_strerror(int);
119 extern acl_t *acl_dup(acl_t *);
120 extern int acl_type(acl_t *);
121 extern int acl_cnt(acl_t *);
122 extern int acl_flags(acl_t *);
123 extern void *acl_data(acl_t *);
124 extern void acl_error(const char *, ...);
125 extern int acl_parse(const char *, acl_t **);
126 extern int yyparse(void);
127 extern void yyreset(void);
128 extern void yycleanup(void);
129 extern acl_t *acl_to_aclp(enum acl_type, void *, int);
130 
131 #ifdef	__cplusplus
132 }
133 #endif
134 
135 #endif /* _ACLUTILS_H */
136