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 /* 227057Smarks * Copyright 2008 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 #include <sys/types.h> 305331Samw #include <sys/acl.h> 311420Smarks #include <strings.h> 321420Smarks #include <locale.h> 331420Smarks #include <ctype.h> 341420Smarks #include <grp.h> 351420Smarks #include <pwd.h> 36789Sahrens 37789Sahrens #ifdef __cplusplus 38789Sahrens extern "C" { 39789Sahrens #endif 40789Sahrens 41789Sahrens #define ACL_REMOVE_ALL 0x0 42789Sahrens #define ACL_REMOVE_FIRST 0x1 43789Sahrens 44789Sahrens /* 45789Sahrens * Hint for whether acl_totext() should use 462097Ssjelinek * mnemonics: 47789Sahrens * read_data/list_directory 48789Sahrens * write_data/add_file or 49789Sahrens * append_data/add_subdirectory 50789Sahrens * when object of ACL is known. 51789Sahrens */ 52789Sahrens 531420Smarks #define PERM_TYPE_ACE 0x1 /* permissions are of ACE type */ 541420Smarks #define PERM_TYPE_UNKNOWN 0x2 /* permission type not yet known */ 551420Smarks #define PERM_TYPE_EMPTY 0x4 /* no permissions are specified */ 561420Smarks 571420Smarks struct acl_perm_type { 581420Smarks int perm_style; /* type of perm style, see above */ 591420Smarks char *perm_str; /* string value being returned */ 601420Smarks uint32_t perm_val; /* numeric value being returned */ 611420Smarks }; 621420Smarks 635344Stz204579 /* 645344Stz204579 * Textual representation of ace_t's access mask 655344Stz204579 */ 665344Stz204579 #define READ_DATA_TXT "read_data/" 675344Stz204579 #define WRITE_DATA_TXT "write_data/" 685344Stz204579 #define EXECUTE_TXT "execute/" 695344Stz204579 #define READ_XATTR_TXT "read_xattr/" 705344Stz204579 #define WRITE_XATTR_TXT "write_xattr/" 715344Stz204579 #define READ_ATTRIBUTES_TXT "read_attributes/" 725344Stz204579 #define WRITE_ATTRIBUTES_TXT "write_attributes/" 735344Stz204579 #define DELETE_TXT "delete/" 745344Stz204579 #define DELETE_CHILD_TXT "delete_child/" 755344Stz204579 #define WRITE_OWNER_TXT "write_owner/" 765344Stz204579 #define READ_ACL_TXT "read_acl/" 775344Stz204579 #define WRITE_ACL_TXT "write_acl/" 785344Stz204579 #define APPEND_DATA_TXT "append_data/" 795344Stz204579 #define READ_DIR_TXT "list_directory/read_data/" 805344Stz204579 #define ADD_DIR_TXT "add_subdirectory/append_data/" 815344Stz204579 #define ADD_FILE_TXT "add_file/write_data/" 827057Smarks #define SYNCHRONIZE_TXT "synchronize/" 835344Stz204579 845344Stz204579 /* 857057Smarks * ace_t's entry types 865344Stz204579 */ 877057Smarks #define OWNERAT_TXT "owner@:" 887057Smarks #define GROUPAT_TXT "group@:" 897057Smarks #define EVERYONEAT_TXT "everyone@:" 905344Stz204579 #define GROUP_TXT "group:" 915344Stz204579 #define USER_TXT "user:" 927057Smarks #define USERSID_TXT "usersid:" 937057Smarks #define GROUPSID_TXT "groupsid:" 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 1047057Smarks /* 1057057Smarks * ace_t's inheritance types 1067057Smarks */ 1077057Smarks 1087057Smarks #define FILE_INHERIT_TXT "file_inherit/" 1097057Smarks #define DIR_INHERIT_TXT "dir_inherit/" 1107057Smarks #define NO_PROPAGATE_TXT "no_propagate/" 1117057Smarks #define INHERIT_ONLY_TXT "inherit_only/" 1127057Smarks #define INHERITED_ACE_TXT "inherited/" 1137057Smarks #define SUCCESSFUL_ACCESS_TXT "successful_access/" 1147057Smarks #define FAILED_ACCESS_TXT "failed_access/" 1157057Smarks 1161420Smarks extern char *yybuf; 1171420Smarks extern acl_t *yyacl; 1181420Smarks 1191420Smarks extern int yyerror(const char *); 1207057Smarks extern int get_id(int entry_type, char *name, uid_t *id); 121*8268SMark.Shellenbaum@Sun.COM extern int get_id_nofail(int entry_type, char *name); 1221420Smarks extern int ace_entry_type(int entry_type); 1231420Smarks extern int aclent_entry_type(int type, int owning, int *ret); 1241420Smarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask); 1251420Smarks extern int compute_aclent_perms(char *str, o_mode_t *mask); 1261420Smarks extern int compute_ace_inherit(char *str, uint32_t *imask); 127789Sahrens extern int acl_addentries(acl_t *, acl_t *, int); 128789Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int); 129789Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int); 1301420Smarks extern void acl_printacl(acl_t *, int, int); 131789Sahrens extern char *acl_strerror(int); 132789Sahrens extern acl_t *acl_dup(acl_t *); 133789Sahrens extern int acl_type(acl_t *); 134789Sahrens extern int acl_cnt(acl_t *); 135789Sahrens extern int acl_flags(acl_t *); 136789Sahrens extern void *acl_data(acl_t *); 1371420Smarks extern void acl_error(const char *, ...); 1381420Smarks extern int acl_parse(const char *, acl_t **); 1391420Smarks extern int yyparse(void); 1401420Smarks extern void yyreset(void); 1415480Smarks extern void yycleanup(void); 1421953Smarks extern acl_t *acl_to_aclp(enum acl_type, void *, int); 1437057Smarks extern int sid_to_id(char *, boolean_t, uid_t *); 144789Sahrens 145789Sahrens #ifdef __cplusplus 146789Sahrens } 147789Sahrens #endif 148789Sahrens 149789Sahrens #endif /* _ACLUTILS_H */ 150