1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 51953Smarks * Common Development and Distribution License (the "License"). 61953Smarks * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 21789Sahrens /* 225331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23789Sahrens * Use is subject to license terms. 24789Sahrens */ 25789Sahrens 26789Sahrens #ifndef _ACLUTILS_H 27789Sahrens #define _ACLUTILS_H 28789Sahrens 29789Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 30789Sahrens 31789Sahrens #include <sys/types.h> 325331Samw #include <sys/acl.h> 331420Smarks #include <strings.h> 341420Smarks #include <locale.h> 351420Smarks #include <ctype.h> 361420Smarks #include <grp.h> 371420Smarks #include <pwd.h> 38789Sahrens 39789Sahrens #ifdef __cplusplus 40789Sahrens extern "C" { 41789Sahrens #endif 42789Sahrens 43789Sahrens #define ACL_REMOVE_ALL 0x0 44789Sahrens #define ACL_REMOVE_FIRST 0x1 45789Sahrens 46789Sahrens /* 47789Sahrens * Hint for whether acl_totext() should use 482097Ssjelinek * mnemonics: 49789Sahrens * read_data/list_directory 50789Sahrens * write_data/add_file or 51789Sahrens * append_data/add_subdirectory 52789Sahrens * when object of ACL is known. 53789Sahrens */ 54789Sahrens 551420Smarks #define PERM_TYPE_ACE 0x1 /* permissions are of ACE type */ 561420Smarks #define PERM_TYPE_UNKNOWN 0x2 /* permission type not yet known */ 571420Smarks #define PERM_TYPE_EMPTY 0x4 /* no permissions are specified */ 581420Smarks 591420Smarks struct acl_perm_type { 601420Smarks int perm_style; /* type of perm style, see above */ 611420Smarks char *perm_str; /* string value being returned */ 621420Smarks uint32_t perm_val; /* numeric value being returned */ 631420Smarks }; 641420Smarks 655344Stz204579 /* 665344Stz204579 * Textual representation of ace_t's access mask 675344Stz204579 */ 685344Stz204579 #define READ_DATA_TXT "read_data/" 695344Stz204579 #define WRITE_DATA_TXT "write_data/" 705344Stz204579 #define EXECUTE_TXT "execute/" 715344Stz204579 #define READ_XATTR_TXT "read_xattr/" 725344Stz204579 #define WRITE_XATTR_TXT "write_xattr/" 735344Stz204579 #define READ_ATTRIBUTES_TXT "read_attributes/" 745344Stz204579 #define WRITE_ATTRIBUTES_TXT "write_attributes/" 755344Stz204579 #define DELETE_TXT "delete/" 765344Stz204579 #define DELETE_CHILD_TXT "delete_child/" 775344Stz204579 #define WRITE_OWNER_TXT "write_owner/" 785344Stz204579 #define READ_ACL_TXT "read_acl/" 795344Stz204579 #define WRITE_ACL_TXT "write_acl/" 805344Stz204579 #define APPEND_DATA_TXT "append_data/" 815344Stz204579 #define READ_DIR_TXT "list_directory/read_data/" 825344Stz204579 #define ADD_DIR_TXT "add_subdirectory/append_data/" 835344Stz204579 #define ADD_FILE_TXT "add_file/write_data/" 845344Stz204579 #define SYNCHRONIZE_TXT "synchronize" /* not slash on this one */ 855344Stz204579 865344Stz204579 /* 875344Stz204579 * ace_t's flags 885344Stz204579 */ 895344Stz204579 #define OWNERAT_TXT "owner@" 905344Stz204579 #define GROUPAT_TXT "group@" 915344Stz204579 #define EVERYONEAT_TXT "everyone@" 925344Stz204579 #define GROUP_TXT "group:" 935344Stz204579 #define USER_TXT "user:" 945344Stz204579 955344Stz204579 /* 965344Stz204579 * ace_t's access types 975344Stz204579 */ 985344Stz204579 #define ALLOW_TXT "allow" 995344Stz204579 #define DENY_TXT "deny" 1005344Stz204579 #define ALARM_TXT "alarm" 1015344Stz204579 #define AUDIT_TXT "audit" 1025344Stz204579 #define UNKNOWN_TXT "unknown" 1035344Stz204579 1041420Smarks extern char *yybuf; 1051420Smarks extern acl_t *yyacl; 1061420Smarks 1071420Smarks extern int yyerror(const char *); 1081420Smarks extern int get_id(int entry_type, char *name, int *id); 1091420Smarks extern int ace_entry_type(int entry_type); 1101420Smarks extern int aclent_entry_type(int type, int owning, int *ret); 1111420Smarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask); 1121420Smarks extern int compute_aclent_perms(char *str, o_mode_t *mask); 1131420Smarks extern int compute_ace_inherit(char *str, uint32_t *imask); 114789Sahrens extern int acl_addentries(acl_t *, acl_t *, int); 115789Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int); 116789Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int); 1171420Smarks extern void acl_printacl(acl_t *, int, int); 118789Sahrens extern char *acl_strerror(int); 119789Sahrens extern acl_t *acl_dup(acl_t *); 120789Sahrens extern int acl_type(acl_t *); 121789Sahrens extern int acl_cnt(acl_t *); 122789Sahrens extern int acl_flags(acl_t *); 123789Sahrens extern void *acl_data(acl_t *); 1241420Smarks extern void acl_error(const char *, ...); 1251420Smarks extern int acl_parse(const char *, acl_t **); 1261420Smarks extern int yyparse(void); 1271420Smarks extern void yyreset(void); 128*5480Smarks extern void yycleanup(void); 1291953Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int); 130789Sahrens 131789Sahrens #ifdef __cplusplus 132789Sahrens } 133789Sahrens #endif 134789Sahrens 135789Sahrens #endif /* _ACLUTILS_H */ 136