1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
51953Smarks  * Common Development and Distribution License (the "License").
61953Smarks  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
22*7057Smarks  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23789Sahrens  * Use is subject to license terms.
24789Sahrens  */
25789Sahrens 
26789Sahrens #ifndef _ACLUTILS_H
27789Sahrens #define	_ACLUTILS_H
28789Sahrens 
29789Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
30789Sahrens 
31789Sahrens #include <sys/types.h>
325331Samw #include <sys/acl.h>
331420Smarks #include <strings.h>
341420Smarks #include <locale.h>
351420Smarks #include <ctype.h>
361420Smarks #include <grp.h>
371420Smarks #include <pwd.h>
38789Sahrens 
39789Sahrens #ifdef	__cplusplus
40789Sahrens extern "C" {
41789Sahrens #endif
42789Sahrens 
43789Sahrens #define	ACL_REMOVE_ALL		0x0
44789Sahrens #define	ACL_REMOVE_FIRST	0x1
45789Sahrens 
46789Sahrens /*
47789Sahrens  * Hint for whether acl_totext() should use
482097Ssjelinek  * mnemonics:
49789Sahrens  * read_data/list_directory
50789Sahrens  * write_data/add_file or
51789Sahrens  * append_data/add_subdirectory
52789Sahrens  * when object of ACL is known.
53789Sahrens  */
54789Sahrens 
551420Smarks #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
561420Smarks #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
571420Smarks #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
581420Smarks 
591420Smarks struct acl_perm_type {
601420Smarks 	int		perm_style;	/* type of perm style, see above */
611420Smarks 	char		*perm_str;	/* string value being returned */
621420Smarks 	uint32_t	perm_val;	/* numeric value being returned */
631420Smarks };
641420Smarks 
655344Stz204579 /*
665344Stz204579  * Textual representation of ace_t's access mask
675344Stz204579  */
685344Stz204579 #define	READ_DATA_TXT	"read_data/"
695344Stz204579 #define	WRITE_DATA_TXT	"write_data/"
705344Stz204579 #define	EXECUTE_TXT	"execute/"
715344Stz204579 #define	READ_XATTR_TXT	"read_xattr/"
725344Stz204579 #define	WRITE_XATTR_TXT	"write_xattr/"
735344Stz204579 #define	READ_ATTRIBUTES_TXT "read_attributes/"
745344Stz204579 #define	WRITE_ATTRIBUTES_TXT "write_attributes/"
755344Stz204579 #define	DELETE_TXT	"delete/"
765344Stz204579 #define	DELETE_CHILD_TXT "delete_child/"
775344Stz204579 #define	WRITE_OWNER_TXT "write_owner/"
785344Stz204579 #define	READ_ACL_TXT	"read_acl/"
795344Stz204579 #define	WRITE_ACL_TXT	"write_acl/"
805344Stz204579 #define	APPEND_DATA_TXT "append_data/"
815344Stz204579 #define	READ_DIR_TXT	"list_directory/read_data/"
825344Stz204579 #define	ADD_DIR_TXT	"add_subdirectory/append_data/"
835344Stz204579 #define	ADD_FILE_TXT	"add_file/write_data/"
84*7057Smarks #define	SYNCHRONIZE_TXT "synchronize/"
855344Stz204579 
865344Stz204579 /*
87*7057Smarks  * ace_t's entry types
885344Stz204579  */
89*7057Smarks #define	OWNERAT_TXT	"owner@:"
90*7057Smarks #define	GROUPAT_TXT	"group@:"
91*7057Smarks #define	EVERYONEAT_TXT	"everyone@:"
925344Stz204579 #define	GROUP_TXT	"group:"
935344Stz204579 #define	USER_TXT	"user:"
94*7057Smarks #define	USERSID_TXT	"usersid:"
95*7057Smarks #define	GROUPSID_TXT	"groupsid:"
965344Stz204579 
975344Stz204579 /*
985344Stz204579  * ace_t's access types
995344Stz204579  */
1005344Stz204579 #define	ALLOW_TXT	"allow"
1015344Stz204579 #define	DENY_TXT	"deny"
1025344Stz204579 #define	ALARM_TXT	"alarm"
1035344Stz204579 #define	AUDIT_TXT	"audit"
1045344Stz204579 #define	UNKNOWN_TXT	"unknown"
1055344Stz204579 
106*7057Smarks /*
107*7057Smarks  * ace_t's inheritance types
108*7057Smarks  */
109*7057Smarks 
110*7057Smarks #define	FILE_INHERIT_TXT	"file_inherit/"
111*7057Smarks #define	DIR_INHERIT_TXT		"dir_inherit/"
112*7057Smarks #define	NO_PROPAGATE_TXT	"no_propagate/"
113*7057Smarks #define	INHERIT_ONLY_TXT	"inherit_only/"
114*7057Smarks #define	INHERITED_ACE_TXT	"inherited/"
115*7057Smarks #define	SUCCESSFUL_ACCESS_TXT	"successful_access/"
116*7057Smarks #define	FAILED_ACCESS_TXT	"failed_access/"
117*7057Smarks 
1181420Smarks extern char *yybuf;
1191420Smarks extern acl_t *yyacl;
1201420Smarks 
1211420Smarks extern int yyerror(const char *);
122*7057Smarks extern int get_id(int entry_type, char *name, uid_t *id);
1231420Smarks extern int ace_entry_type(int entry_type);
1241420Smarks extern int aclent_entry_type(int type, int owning, int *ret);
1251420Smarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
1261420Smarks extern int compute_aclent_perms(char *str, o_mode_t *mask);
1271420Smarks extern int compute_ace_inherit(char *str, uint32_t *imask);
128789Sahrens extern int acl_addentries(acl_t *, acl_t *, int);
129789Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int);
130789Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int);
1311420Smarks extern void acl_printacl(acl_t *, int, int);
132789Sahrens extern char *acl_strerror(int);
133789Sahrens extern acl_t *acl_dup(acl_t *);
134789Sahrens extern int acl_type(acl_t *);
135789Sahrens extern int acl_cnt(acl_t *);
136789Sahrens extern int acl_flags(acl_t *);
137789Sahrens extern void *acl_data(acl_t *);
1381420Smarks extern void acl_error(const char *, ...);
1391420Smarks extern int acl_parse(const char *, acl_t **);
1401420Smarks extern int yyparse(void);
1411420Smarks extern void yyreset(void);
1425480Smarks extern void yycleanup(void);
1431953Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int);
144*7057Smarks extern int sid_to_id(char *, boolean_t, uid_t *);
145789Sahrens 
146789Sahrens #ifdef	__cplusplus
147789Sahrens }
148789Sahrens #endif
149789Sahrens 
150789Sahrens #endif /* _ACLUTILS_H */
151