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