1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 5789Sahrens * Common Development and Distribution License, Version 1.0 only 6789Sahrens * (the "License"). You may not use this file except in compliance 7789Sahrens * with the License. 8789Sahrens * 9789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10789Sahrens * or http://www.opensolaris.org/os/licensing. 11789Sahrens * See the License for the specific language governing permissions 12789Sahrens * and limitations under the License. 13789Sahrens * 14789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 15789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16789Sahrens * If applicable, add the following below this CDDL HEADER, with the 17789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 18789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 19789Sahrens * 20789Sahrens * CDDL HEADER END 21789Sahrens */ 22789Sahrens /* 23*1420Smarks * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24789Sahrens * Use is subject to license terms. 25789Sahrens */ 26789Sahrens 27789Sahrens #ifndef _ACLUTILS_H 28789Sahrens #define _ACLUTILS_H 29789Sahrens 30789Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 31789Sahrens 32789Sahrens #include <sys/types.h> 33*1420Smarks #include <strings.h> 34*1420Smarks #include <locale.h> 35*1420Smarks #include <ctype.h> 36*1420Smarks #include <grp.h> 37*1420Smarks #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 48789Sahrens * mneumonics: 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 #define ACL_IS_DIR 0x2 55789Sahrens 56789Sahrens typedef enum acl_type { 57789Sahrens ACLENT_T = 0, 58789Sahrens ACE_T = 1 59789Sahrens } acl_type_t; 60789Sahrens 61789Sahrens /* 62789Sahrens * acl flags 63789Sahrens */ 64789Sahrens #define ACL_IS_TRIVIAL 0x1 65789Sahrens 66789Sahrens struct acl_info { 67789Sahrens acl_type_t acl_type; /* style of acl */ 68789Sahrens int acl_cnt; /* number of acl entries */ 69789Sahrens int acl_entry_size; /* sizeof acl entry */ 70789Sahrens int acl_flags; /* special flags about acl */ 71789Sahrens void *acl_aclp; /* the acl */ 72789Sahrens }; 73789Sahrens 74789Sahrens 75*1420Smarks #define PERM_TYPE_ACE 0x1 /* permissions are of ACE type */ 76*1420Smarks #define PERM_TYPE_UNKNOWN 0x2 /* permission type not yet known */ 77*1420Smarks #define PERM_TYPE_EMPTY 0x4 /* no permissions are specified */ 78*1420Smarks 79*1420Smarks struct acl_perm_type { 80*1420Smarks int perm_style; /* type of perm style, see above */ 81*1420Smarks char *perm_str; /* string value being returned */ 82*1420Smarks uint32_t perm_val; /* numeric value being returned */ 83*1420Smarks }; 84*1420Smarks 85*1420Smarks extern char *yybuf; 86*1420Smarks extern acl_t *yyacl; 87*1420Smarks 88*1420Smarks extern int yyerror(const char *); 89*1420Smarks extern int get_id(int entry_type, char *name, int *id); 90*1420Smarks extern int ace_entry_type(int entry_type); 91*1420Smarks extern int aclent_entry_type(int type, int owning, int *ret); 92*1420Smarks extern int ace_perm_mask(struct acl_perm_type *, uint32_t *mask); 93*1420Smarks extern int compute_aclent_perms(char *str, o_mode_t *mask); 94*1420Smarks extern int compute_ace_inherit(char *str, uint32_t *imask); 95789Sahrens extern int acl_addentries(acl_t *, acl_t *, int); 96789Sahrens extern int acl_removeentries(acl_t *, acl_t *, int, int); 97789Sahrens extern int acl_modifyentries(acl_t *, acl_t *, int); 98*1420Smarks extern void acl_printacl(acl_t *, int, int); 99789Sahrens extern char *acl_strerror(int); 100789Sahrens extern acl_t *acl_dup(acl_t *); 101789Sahrens extern int acl_type(acl_t *); 102789Sahrens extern int acl_cnt(acl_t *); 103789Sahrens extern int acl_flags(acl_t *); 104789Sahrens extern void *acl_data(acl_t *); 105*1420Smarks extern void acl_error(const char *, ...); 106*1420Smarks extern int acl_parse(const char *, acl_t **); 107*1420Smarks extern int yyparse(void); 108*1420Smarks extern void yyreset(void); 109*1420Smarks extern acl_t *acl_alloc(enum acl_type); 110789Sahrens 111789Sahrens #ifdef __cplusplus 112789Sahrens } 113789Sahrens #endif 114789Sahrens 115789Sahrens #endif /* _ACLUTILS_H */ 116