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 /*
221420Smarks  * Copyright 2006 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>
321420Smarks #include <strings.h>
331420Smarks #include <locale.h>
341420Smarks #include <ctype.h>
351420Smarks #include <grp.h>
361420Smarks #include <pwd.h>
37789Sahrens 
38789Sahrens #ifdef	__cplusplus
39789Sahrens extern "C" {
40789Sahrens #endif
41789Sahrens 
42789Sahrens #define	ACL_REMOVE_ALL		0x0
43789Sahrens #define	ACL_REMOVE_FIRST	0x1
44789Sahrens 
45789Sahrens /*
46789Sahrens  * Hint for whether acl_totext() should use
47*2097Ssjelinek  * mnemonics:
48789Sahrens  * read_data/list_directory
49789Sahrens  * write_data/add_file or
50789Sahrens  * append_data/add_subdirectory
51789Sahrens  * when object of ACL is known.
52789Sahrens  */
53789Sahrens #define	ACL_IS_DIR	0x2
54789Sahrens 
55789Sahrens typedef enum acl_type {
56789Sahrens 	ACLENT_T = 0,
57789Sahrens 	ACE_T = 1
58789Sahrens } acl_type_t;
59789Sahrens 
60789Sahrens /*
61789Sahrens  * acl flags
62789Sahrens  */
63789Sahrens #define	ACL_IS_TRIVIAL	0x1
64789Sahrens 
65789Sahrens struct acl_info {
66789Sahrens 	acl_type_t acl_type;		/* style of acl */
67789Sahrens 	int acl_cnt;			/* number of acl entries */
68789Sahrens 	int acl_entry_size;		/* sizeof acl entry */
69789Sahrens 	int acl_flags;			/* special flags about acl */
70789Sahrens 	void *acl_aclp;			/* the acl */
71789Sahrens };
72789Sahrens 
73789Sahrens 
741420Smarks #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
751420Smarks #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
761420Smarks #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
771420Smarks 
781420Smarks struct acl_perm_type {
791420Smarks 	int		perm_style;	/* type of perm style, see above */
801420Smarks 	char		*perm_str;	/* string value being returned */
811420Smarks 	uint32_t	perm_val;	/* numeric value being returned */
821420Smarks };
831420Smarks 
841420Smarks extern char *yybuf;
851420Smarks extern acl_t *yyacl;
861420Smarks 
871420Smarks extern int yyerror(const char *);
881420Smarks extern int get_id(int entry_type, char *name, int *id);
891420Smarks extern int ace_entry_type(int entry_type);
901420Smarks extern int aclent_entry_type(int type, int owning, int *ret);
911420Smarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
921420Smarks extern int compute_aclent_perms(char *str, o_mode_t *mask);
931420Smarks extern int compute_ace_inherit(char *str, uint32_t *imask);
94789Sahrens extern int acl_addentries(acl_t *, acl_t *, int);
95789Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int);
96789Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int);
971420Smarks extern void acl_printacl(acl_t *, int, int);
98789Sahrens extern char *acl_strerror(int);
99789Sahrens extern acl_t *acl_dup(acl_t *);
100789Sahrens extern int acl_type(acl_t *);
101789Sahrens extern int acl_cnt(acl_t *);
102789Sahrens extern int acl_flags(acl_t *);
103789Sahrens extern void *acl_data(acl_t *);
1041420Smarks extern void acl_error(const char *, ...);
1051420Smarks extern int acl_parse(const char *, acl_t **);
1061420Smarks extern int yyparse(void);
1071420Smarks extern void yyreset(void);
1081420Smarks extern acl_t *acl_alloc(enum acl_type);
1091953Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int);
110789Sahrens 
111789Sahrens #ifdef	__cplusplus
112789Sahrens }
113789Sahrens #endif
114789Sahrens 
115789Sahrens #endif /* _ACLUTILS_H */
116