xref: /titanic_41/usr/src/lib/libsec/common/aclutils.h (revision a2bb96e7d59f447f59bc306e53b7d00e38594667)
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 _ACLUTILS_H
27 #define	_ACLUTILS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <strings.h>
33 #include <locale.h>
34 #include <ctype.h>
35 #include <grp.h>
36 #include <pwd.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	ACL_REMOVE_ALL		0x0
43 #define	ACL_REMOVE_FIRST	0x1
44 
45 /*
46  * Hint for whether acl_totext() should use
47  * mnemonics:
48  * read_data/list_directory
49  * write_data/add_file or
50  * append_data/add_subdirectory
51  * when object of ACL is known.
52  */
53 #define	ACL_IS_DIR	0x2
54 
55 typedef enum acl_type {
56 	ACLENT_T = 0,
57 	ACE_T = 1
58 } acl_type_t;
59 
60 /*
61  * acl flags
62  */
63 #define	ACL_IS_TRIVIAL	0x1
64 
65 struct acl_info {
66 	acl_type_t acl_type;		/* style of acl */
67 	int acl_cnt;			/* number of acl entries */
68 	int acl_entry_size;		/* sizeof acl entry */
69 	int acl_flags;			/* special flags about acl */
70 	void *acl_aclp;			/* the acl */
71 };
72 
73 
74 #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
75 #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
76 #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
77 
78 struct acl_perm_type {
79 	int		perm_style;	/* type of perm style, see above */
80 	char		*perm_str;	/* string value being returned */
81 	uint32_t	perm_val;	/* numeric value being returned */
82 };
83 
84 extern char *yybuf;
85 extern acl_t *yyacl;
86 
87 extern int yyerror(const char *);
88 extern int get_id(int entry_type, char *name, int *id);
89 extern int ace_entry_type(int entry_type);
90 extern int aclent_entry_type(int type, int owning, int *ret);
91 extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
92 extern int compute_aclent_perms(char *str, o_mode_t *mask);
93 extern int compute_ace_inherit(char *str, uint32_t *imask);
94 extern int acl_addentries(acl_t *, acl_t *, int);
95 extern int acl_removeentries(acl_t *, acl_t *, int, int);
96 extern int acl_modifyentries(acl_t *, acl_t *, int);
97 extern void acl_printacl(acl_t *, int, int);
98 extern char *acl_strerror(int);
99 extern acl_t *acl_dup(acl_t *);
100 extern int acl_type(acl_t *);
101 extern int acl_cnt(acl_t *);
102 extern int acl_flags(acl_t *);
103 extern void *acl_data(acl_t *);
104 extern void acl_error(const char *, ...);
105 extern int acl_parse(const char *, acl_t **);
106 extern int yyparse(void);
107 extern void yyreset(void);
108 extern acl_t *acl_alloc(enum acl_type);
109 extern acl_t *acl_to_aclp(enum acl_type, void *, int);
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif /* _ACLUTILS_H */
116