1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5*49f0e518Smarks * Common Development and Distribution License (the "License"). 6*49f0e518Smarks * 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 /* 225a5eeccaSmarks * Copyright 2006 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> 325a5eeccaSmarks #include <strings.h> 335a5eeccaSmarks #include <locale.h> 345a5eeccaSmarks #include <ctype.h> 355a5eeccaSmarks #include <grp.h> 365a5eeccaSmarks #include <pwd.h> 37fa9e4066Sahrens 38fa9e4066Sahrens #ifdef __cplusplus 39fa9e4066Sahrens extern "C" { 40fa9e4066Sahrens #endif 41fa9e4066Sahrens 42fa9e4066Sahrens #define ACL_REMOVE_ALL 0x0 43fa9e4066Sahrens #define ACL_REMOVE_FIRST 0x1 44fa9e4066Sahrens 45fa9e4066Sahrens /* 46fa9e4066Sahrens * Hint for whether acl_totext() should use 47fa9e4066Sahrens * mneumonics: 48fa9e4066Sahrens * read_data/list_directory 49fa9e4066Sahrens * write_data/add_file or 50fa9e4066Sahrens * append_data/add_subdirectory 51fa9e4066Sahrens * when object of ACL is known. 52fa9e4066Sahrens */ 53fa9e4066Sahrens #define ACL_IS_DIR 0x2 54fa9e4066Sahrens 55fa9e4066Sahrens typedef enum acl_type { 56fa9e4066Sahrens ACLENT_T = 0, 57fa9e4066Sahrens ACE_T = 1 58fa9e4066Sahrens } acl_type_t; 59fa9e4066Sahrens 60fa9e4066Sahrens /* 61fa9e4066Sahrens * acl flags 62fa9e4066Sahrens */ 63fa9e4066Sahrens #define ACL_IS_TRIVIAL 0x1 64fa9e4066Sahrens 65fa9e4066Sahrens struct acl_info { 66fa9e4066Sahrens acl_type_t acl_type; /* style of acl */ 67fa9e4066Sahrens int acl_cnt; /* number of acl entries */ 68fa9e4066Sahrens int acl_entry_size; /* sizeof acl entry */ 69fa9e4066Sahrens int acl_flags; /* special flags about acl */ 70fa9e4066Sahrens void *acl_aclp; /* the acl */ 71fa9e4066Sahrens }; 72fa9e4066Sahrens 73fa9e4066Sahrens 745a5eeccaSmarks #define PERM_TYPE_ACE 0x1 /* permissions are of ACE type */ 755a5eeccaSmarks #define PERM_TYPE_UNKNOWN 0x2 /* permission type not yet known */ 765a5eeccaSmarks #define PERM_TYPE_EMPTY 0x4 /* no permissions are specified */ 775a5eeccaSmarks 785a5eeccaSmarks struct acl_perm_type { 795a5eeccaSmarks int perm_style; /* type of perm style, see above */ 805a5eeccaSmarks char *perm_str; /* string value being returned */ 815a5eeccaSmarks uint32_t perm_val; /* numeric value being returned */ 825a5eeccaSmarks }; 835a5eeccaSmarks 845a5eeccaSmarks extern char *yybuf; 855a5eeccaSmarks extern acl_t *yyacl; 865a5eeccaSmarks 875a5eeccaSmarks extern int yyerror(const char *); 885a5eeccaSmarks extern int get_id(int entry_type, char *name, int *id); 895a5eeccaSmarks extern int ace_entry_type(int entry_type); 905a5eeccaSmarks extern int aclent_entry_type(int type, int owning, int *ret); 915a5eeccaSmarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask); 925a5eeccaSmarks extern int compute_aclent_perms(char *str, o_mode_t *mask); 935a5eeccaSmarks extern int compute_ace_inherit(char *str, uint32_t *imask); 94fa9e4066Sahrens extern int acl_addentries(acl_t *, acl_t *, int); 95fa9e4066Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int); 96fa9e4066Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int); 975a5eeccaSmarks extern void acl_printacl(acl_t *, int, int); 98fa9e4066Sahrens extern char *acl_strerror(int); 99fa9e4066Sahrens extern acl_t *acl_dup(acl_t *); 100fa9e4066Sahrens extern int acl_type(acl_t *); 101fa9e4066Sahrens extern int acl_cnt(acl_t *); 102fa9e4066Sahrens extern int acl_flags(acl_t *); 103fa9e4066Sahrens extern void *acl_data(acl_t *); 1045a5eeccaSmarks extern void acl_error(const char *, ...); 1055a5eeccaSmarks extern int acl_parse(const char *, acl_t **); 1065a5eeccaSmarks extern int yyparse(void); 1075a5eeccaSmarks extern void yyreset(void); 1085a5eeccaSmarks extern acl_t *acl_alloc(enum acl_type); 109*49f0e518Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int); 110fa9e4066Sahrens 111fa9e4066Sahrens #ifdef __cplusplus 112fa9e4066Sahrens } 113fa9e4066Sahrens #endif 114fa9e4066Sahrens 115fa9e4066Sahrens #endif /* _ACLUTILS_H */ 116