xref: /titanic_52/usr/src/lib/libsec/common/aclutils.h (revision 10db1377dafab8ba3feedef26db9c5d8539a5cd1)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _ACLUTILS_H
28 #define	_ACLUTILS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.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  * mneumonics:
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 #define	ACL_IS_DIR	0x2
55 
56 typedef enum acl_type {
57 	ACLENT_T = 0,
58 	ACE_T = 1
59 } acl_type_t;
60 
61 /*
62  * acl flags
63  */
64 #define	ACL_IS_TRIVIAL	0x1
65 
66 struct acl_info {
67 	acl_type_t acl_type;		/* style of acl */
68 	int acl_cnt;			/* number of acl entries */
69 	int acl_entry_size;		/* sizeof acl entry */
70 	int acl_flags;			/* special flags about acl */
71 	void *acl_aclp;			/* the acl */
72 };
73 
74 
75 #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
76 #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
77 #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
78 
79 struct acl_perm_type {
80 	int		perm_style;	/* type of perm style, see above */
81 	char		*perm_str;	/* string value being returned */
82 	uint32_t	perm_val;	/* numeric value being returned */
83 };
84 
85 extern char *yybuf;
86 extern acl_t *yyacl;
87 
88 extern int yyerror(const char *);
89 extern int get_id(int entry_type, char *name, int *id);
90 extern int ace_entry_type(int entry_type);
91 extern int aclent_entry_type(int type, int owning, int *ret);
92 extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
93 extern int compute_aclent_perms(char *str, o_mode_t *mask);
94 extern int compute_ace_inherit(char *str, uint32_t *imask);
95 extern int acl_addentries(acl_t *, acl_t *, int);
96 extern int acl_removeentries(acl_t *, acl_t *, int, int);
97 extern int acl_modifyentries(acl_t *, acl_t *, int);
98 extern void acl_printacl(acl_t *, int, int);
99 extern char *acl_strerror(int);
100 extern acl_t *acl_dup(acl_t *);
101 extern int acl_type(acl_t *);
102 extern int acl_cnt(acl_t *);
103 extern int acl_flags(acl_t *);
104 extern void *acl_data(acl_t *);
105 extern void acl_error(const char *, ...);
106 extern int acl_parse(const char *, acl_t **);
107 extern int yyparse(void);
108 extern void yyreset(void);
109 extern acl_t *acl_alloc(enum acl_type);
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif /* _ACLUTILS_H */
116