xref: /titanic_50/usr/src/lib/libsec/common/aclutils.h (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
549f0e518Smarks  * Common Development and Distribution License (the "License").
649f0e518Smarks  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
22*da6c28aaSamw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23fa9e4066Sahrens  * Use is subject to license terms.
24fa9e4066Sahrens  */
25fa9e4066Sahrens 
26fa9e4066Sahrens #ifndef _ACLUTILS_H
27fa9e4066Sahrens #define	_ACLUTILS_H
28fa9e4066Sahrens 
29fa9e4066Sahrens #pragma ident	"%Z%%M%	%I%	%E% SMI"
30fa9e4066Sahrens 
31fa9e4066Sahrens #include <sys/types.h>
32*da6c28aaSamw #include <sys/acl.h>
335a5eeccaSmarks #include <strings.h>
345a5eeccaSmarks #include <locale.h>
355a5eeccaSmarks #include <ctype.h>
365a5eeccaSmarks #include <grp.h>
375a5eeccaSmarks #include <pwd.h>
38fa9e4066Sahrens 
39fa9e4066Sahrens #ifdef	__cplusplus
40fa9e4066Sahrens extern "C" {
41fa9e4066Sahrens #endif
42fa9e4066Sahrens 
43fa9e4066Sahrens #define	ACL_REMOVE_ALL		0x0
44fa9e4066Sahrens #define	ACL_REMOVE_FIRST	0x1
45fa9e4066Sahrens 
46fa9e4066Sahrens /*
47fa9e4066Sahrens  * Hint for whether acl_totext() should use
486deb031bSsjelinek  * mnemonics:
49fa9e4066Sahrens  * read_data/list_directory
50fa9e4066Sahrens  * write_data/add_file or
51fa9e4066Sahrens  * append_data/add_subdirectory
52fa9e4066Sahrens  * when object of ACL is known.
53fa9e4066Sahrens  */
54fa9e4066Sahrens 
555a5eeccaSmarks #define	PERM_TYPE_ACE		0x1	/* permissions are of ACE type */
565a5eeccaSmarks #define	PERM_TYPE_UNKNOWN	0x2	/* permission type not yet known */
575a5eeccaSmarks #define	PERM_TYPE_EMPTY		0x4	/* no permissions are specified */
585a5eeccaSmarks 
595a5eeccaSmarks struct acl_perm_type {
605a5eeccaSmarks 	int		perm_style;	/* type of perm style, see above */
615a5eeccaSmarks 	char		*perm_str;	/* string value being returned */
625a5eeccaSmarks 	uint32_t	perm_val;	/* numeric value being returned */
635a5eeccaSmarks };
645a5eeccaSmarks 
655a5eeccaSmarks extern char *yybuf;
665a5eeccaSmarks extern acl_t *yyacl;
675a5eeccaSmarks 
685a5eeccaSmarks extern int yyerror(const char *);
695a5eeccaSmarks extern int get_id(int entry_type, char *name, int *id);
705a5eeccaSmarks extern int ace_entry_type(int entry_type);
715a5eeccaSmarks extern int aclent_entry_type(int type, int owning, int *ret);
725a5eeccaSmarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask);
735a5eeccaSmarks extern int compute_aclent_perms(char *str, o_mode_t *mask);
745a5eeccaSmarks extern int compute_ace_inherit(char *str, uint32_t *imask);
75fa9e4066Sahrens extern int acl_addentries(acl_t *, acl_t *, int);
76fa9e4066Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int);
77fa9e4066Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int);
785a5eeccaSmarks extern void acl_printacl(acl_t *, int, int);
79fa9e4066Sahrens extern char *acl_strerror(int);
80fa9e4066Sahrens extern acl_t *acl_dup(acl_t *);
81fa9e4066Sahrens extern int acl_type(acl_t *);
82fa9e4066Sahrens extern int acl_cnt(acl_t *);
83fa9e4066Sahrens extern int acl_flags(acl_t *);
84fa9e4066Sahrens extern void *acl_data(acl_t *);
855a5eeccaSmarks extern void acl_error(const char *, ...);
865a5eeccaSmarks extern int acl_parse(const char *, acl_t **);
875a5eeccaSmarks extern int yyparse(void);
885a5eeccaSmarks extern void yyreset(void);
8949f0e518Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int);
90fa9e4066Sahrens 
91fa9e4066Sahrens #ifdef	__cplusplus
92fa9e4066Sahrens }
93fa9e4066Sahrens #endif
94fa9e4066Sahrens 
95fa9e4066Sahrens #endif /* _ACLUTILS_H */
96