10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51507Sgjelinek * Common Development and Distribution License (the "License"). 61507Sgjelinek * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_ACL_H 270Sstevel@tonic-gate #define _SYS_ACL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 32*5331Samw #include <sys/acl_impl.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate #define MAX_ACL_ENTRIES (1024) /* max entries of each type */ 390Sstevel@tonic-gate typedef struct acl { 400Sstevel@tonic-gate int a_type; /* the type of ACL entry */ 410Sstevel@tonic-gate uid_t a_id; /* the entry in -uid or gid */ 420Sstevel@tonic-gate o_mode_t a_perm; /* the permission field */ 430Sstevel@tonic-gate } aclent_t; 440Sstevel@tonic-gate 450Sstevel@tonic-gate typedef struct ace { 460Sstevel@tonic-gate uid_t a_who; /* uid or gid */ 47789Sahrens uint32_t a_access_mask; /* read,write,... */ 480Sstevel@tonic-gate uint16_t a_flags; /* see below */ 490Sstevel@tonic-gate uint16_t a_type; /* allow or deny */ 500Sstevel@tonic-gate } ace_t; 510Sstevel@tonic-gate 52789Sahrens typedef struct acl_info acl_t; 53789Sahrens 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * The following are Defined types for an aclent_t. 560Sstevel@tonic-gate */ 570Sstevel@tonic-gate #define USER_OBJ (0x01) /* object owner */ 580Sstevel@tonic-gate #define USER (0x02) /* additional users */ 590Sstevel@tonic-gate #define GROUP_OBJ (0x04) /* owning group of the object */ 600Sstevel@tonic-gate #define GROUP (0x08) /* additional groups */ 610Sstevel@tonic-gate #define CLASS_OBJ (0x10) /* file group class and mask entry */ 620Sstevel@tonic-gate #define OTHER_OBJ (0x20) /* other entry for the object */ 630Sstevel@tonic-gate #define ACL_DEFAULT (0x1000) /* default flag */ 640Sstevel@tonic-gate /* default object owner */ 650Sstevel@tonic-gate #define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ) 66*5331Samw /* default additional users */ 670Sstevel@tonic-gate #define DEF_USER (ACL_DEFAULT | USER) 680Sstevel@tonic-gate /* default owning group */ 690Sstevel@tonic-gate #define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ) 700Sstevel@tonic-gate /* default additional groups */ 710Sstevel@tonic-gate #define DEF_GROUP (ACL_DEFAULT | GROUP) 720Sstevel@tonic-gate /* default mask entry */ 730Sstevel@tonic-gate #define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ) 740Sstevel@tonic-gate /* default other entry */ 750Sstevel@tonic-gate #define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ) 760Sstevel@tonic-gate 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * The following are defined for ace_t. 790Sstevel@tonic-gate */ 80789Sahrens #define ACE_READ_DATA 0x00000001 81789Sahrens #define ACE_LIST_DIRECTORY 0x00000001 82789Sahrens #define ACE_WRITE_DATA 0x00000002 83789Sahrens #define ACE_ADD_FILE 0x00000002 84789Sahrens #define ACE_APPEND_DATA 0x00000004 85789Sahrens #define ACE_ADD_SUBDIRECTORY 0x00000004 86789Sahrens #define ACE_READ_NAMED_ATTRS 0x00000008 87789Sahrens #define ACE_WRITE_NAMED_ATTRS 0x00000010 88789Sahrens #define ACE_EXECUTE 0x00000020 89789Sahrens #define ACE_DELETE_CHILD 0x00000040 90789Sahrens #define ACE_READ_ATTRIBUTES 0x00000080 91789Sahrens #define ACE_WRITE_ATTRIBUTES 0x00000100 92789Sahrens #define ACE_DELETE 0x00010000 93789Sahrens #define ACE_READ_ACL 0x00020000 94789Sahrens #define ACE_WRITE_ACL 0x00040000 95789Sahrens #define ACE_WRITE_OWNER 0x00080000 96789Sahrens #define ACE_SYNCHRONIZE 0x00100000 97789Sahrens 980Sstevel@tonic-gate #define ACE_FILE_INHERIT_ACE 0x0001 990Sstevel@tonic-gate #define ACE_DIRECTORY_INHERIT_ACE 0x0002 100789Sahrens #define ACE_NO_PROPAGATE_INHERIT_ACE 0x0004 1010Sstevel@tonic-gate #define ACE_INHERIT_ONLY_ACE 0x0008 102789Sahrens #define ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x0010 103789Sahrens #define ACE_FAILED_ACCESS_ACE_FLAG 0x0020 104789Sahrens #define ACE_IDENTIFIER_GROUP 0x0040 105*5331Samw #define ACE_INHERITED_ACE 0x0080 106789Sahrens #define ACE_OWNER 0x1000 107789Sahrens #define ACE_GROUP 0x2000 108789Sahrens #define ACE_EVERYONE 0x4000 109789Sahrens 110789Sahrens #define ACE_ACCESS_ALLOWED_ACE_TYPE 0x0000 111789Sahrens #define ACE_ACCESS_DENIED_ACE_TYPE 0x0001 112789Sahrens #define ACE_SYSTEM_AUDIT_ACE_TYPE 0x0002 113789Sahrens #define ACE_SYSTEM_ALARM_ACE_TYPE 0x0003 114789Sahrens 115*5331Samw #define ACL_AUTO_INHERIT 0x0001 116*5331Samw #define ACL_PROTECTED 0x0002 117*5331Samw #define ACL_DEFAULTED 0x0004 118*5331Samw #define ACL_FLAGS_ALL (ACL_AUTO_INHERIT|ACL_PROTECTED| \ 119*5331Samw ACL_DEFAULTED) 120*5331Samw 121*5331Samw #ifdef _KERNEL 122*5331Samw 123*5331Samw /* 124*5331Samw * These are only applicable in a CIFS context. 125*5331Samw */ 126*5331Samw #define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE 0x04 127*5331Samw #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 128*5331Samw #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 129*5331Samw #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 130*5331Samw #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 131*5331Samw #define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE 0x09 132*5331Samw #define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE 0x0A 133*5331Samw #define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE 0x0B 134*5331Samw #define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE 0x0C 135*5331Samw #define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE 0x0D 136*5331Samw #define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE 0x0E 137*5331Samw #define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE 0x0F 138*5331Samw #define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE 0x10 139*5331Samw 140*5331Samw #define ACE_ALL_TYPES 0x001F 141*5331Samw 142*5331Samw typedef struct ace_object { 143*5331Samw uid_t a_who; /* uid or gid */ 144*5331Samw uint32_t a_access_mask; /* read,write,... */ 145*5331Samw uint16_t a_flags; /* see below */ 146*5331Samw uint16_t a_type; /* allow or deny */ 147*5331Samw uint8_t a_obj_type[16]; /* obj type */ 148*5331Samw uint8_t a_inherit_obj_type[16]; /* inherit obj */ 149*5331Samw } ace_object_t; 150*5331Samw 151*5331Samw #endif 152*5331Samw 153789Sahrens #define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \ 154789Sahrens ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \ 155789Sahrens ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \ 156789Sahrens ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \ 157789Sahrens ACE_WRITE_OWNER|ACE_SYNCHRONIZE) 158789Sahrens 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * The following flags are supported by both NFSv4 ACLs and ace_t. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \ 1630Sstevel@tonic-gate ACE_DIRECTORY_INHERIT_ACE | \ 164789Sahrens ACE_NO_PROPAGATE_INHERIT_ACE | \ 165789Sahrens ACE_INHERIT_ONLY_ACE | \ 166789Sahrens ACE_IDENTIFIER_GROUP) 1670Sstevel@tonic-gate 168*5331Samw #define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \ 169*5331Samw ACE_IDENTIFIER_GROUP) 170*5331Samw #define ACE_INHERIT_FLAGS (ACE_FILE_INHERIT_ACE| \ 171*5331Samw ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE) 1721420Smarks 1730Sstevel@tonic-gate /* cmd args to acl(2) for aclent_t */ 1740Sstevel@tonic-gate #define GETACL 1 1750Sstevel@tonic-gate #define SETACL 2 1760Sstevel@tonic-gate #define GETACLCNT 3 1770Sstevel@tonic-gate 178789Sahrens /* cmd's to manipulate ace acls. */ 1790Sstevel@tonic-gate #define ACE_GETACL 4 1800Sstevel@tonic-gate #define ACE_SETACL 5 1810Sstevel@tonic-gate #define ACE_GETACLCNT 6 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* minimal acl entries from GETACLCNT */ 1840Sstevel@tonic-gate #define MIN_ACL_ENTRIES 4 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate #if !defined(_KERNEL) 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate /* acl check errors */ 1890Sstevel@tonic-gate #define GRP_ERROR 1 1900Sstevel@tonic-gate #define USER_ERROR 2 1910Sstevel@tonic-gate #define OTHER_ERROR 3 1920Sstevel@tonic-gate #define CLASS_ERROR 4 1930Sstevel@tonic-gate #define DUPLICATE_ERROR 5 1940Sstevel@tonic-gate #define MISS_ERROR 6 1950Sstevel@tonic-gate #define MEM_ERROR 7 1960Sstevel@tonic-gate #define ENTRY_ERROR 8 1970Sstevel@tonic-gate 198789Sahrens 1990Sstevel@tonic-gate /* 2000Sstevel@tonic-gate * similar to ufs_acl.h: changed to char type for user commands (tar, cpio) 2010Sstevel@tonic-gate * Attribute types 2020Sstevel@tonic-gate */ 2030Sstevel@tonic-gate #define UFSD_FREE ('0') /* Free entry */ 2040Sstevel@tonic-gate #define UFSD_ACL ('1') /* Access Control Lists */ 2050Sstevel@tonic-gate #define UFSD_DFACL ('2') /* reserved for future use */ 206789Sahrens #define ACE_ACL ('3') /* ace_t style acls */ 207789Sahrens 208789Sahrens /* 209789Sahrens * flag to [f]acl_get() 210789Sahrens * controls whether a trivial acl should be returned. 211789Sahrens */ 212789Sahrens #define ACL_NO_TRIVIAL 0x2 213789Sahrens 2141420Smarks 2151420Smarks /* 2161420Smarks * Flags to control acl_totext() 2171420Smarks */ 2181420Smarks 2191420Smarks #define ACL_APPEND_ID 0x1 /* append uid/gid to user/group entries */ 2201420Smarks #define ACL_COMPACT_FMT 0x2 /* build ACL in ls -V format */ 2211507Sgjelinek #define ACL_NORESOLVE 0x4 /* don't do name service lookups */ 2221420Smarks 223789Sahrens /* 224789Sahrens * Legacy aclcheck errors for aclent_t ACLs 225789Sahrens */ 226789Sahrens #define EACL_GRP_ERROR GRP_ERROR 227789Sahrens #define EACL_USER_ERROR USER_ERROR 228789Sahrens #define EACL_OTHER_ERROR OTHER_ERROR 229789Sahrens #define EACL_CLASS_ERROR CLASS_ERROR 230789Sahrens #define EACL_DUPLICATE_ERROR DUPLICATE_ERROR 231789Sahrens #define EACL_MISS_ERROR MISS_ERROR 232789Sahrens #define EACL_MEM_ERROR MEM_ERROR 233789Sahrens #define EACL_ENTRY_ERROR ENTRY_ERROR 234789Sahrens 235789Sahrens #define EACL_INHERIT_ERROR 9 /* invalid inherit flags */ 236789Sahrens #define EACL_FLAGS_ERROR 10 /* unknown flag value */ 237789Sahrens #define EACL_PERM_MASK_ERROR 11 /* unknown permission */ 238789Sahrens #define EACL_COUNT_ERROR 12 /* invalid acl count */ 239789Sahrens 240789Sahrens #define EACL_INVALID_SLOT 13 /* invalid acl slot */ 241789Sahrens #define EACL_NO_ACL_ENTRY 14 /* Entry doesn't exist */ 242789Sahrens #define EACL_DIFF_TYPE 15 /* acls aren't same type */ 243789Sahrens 244789Sahrens #define EACL_INVALID_USER_GROUP 16 /* need user/group name */ 245789Sahrens #define EACL_INVALID_STR 17 /* invalid acl string */ 246789Sahrens #define EACL_FIELD_NOT_BLANK 18 /* can't have blank field */ 247789Sahrens #define EACL_INVALID_ACCESS_TYPE 19 /* invalid access type */ 248789Sahrens #define EACL_UNKNOWN_DATA 20 /* Unrecognized data in ACL */ 249789Sahrens #define EACL_MISSING_FIELDS 21 /* missing fields in acl */ 250789Sahrens 251789Sahrens #define EACL_INHERIT_NOTDIR 22 /* Need dir for inheritance */ 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate extern int aclcheck(aclent_t *, int, int *); 2540Sstevel@tonic-gate extern int acltomode(aclent_t *, int, mode_t *); 2550Sstevel@tonic-gate extern int aclfrommode(aclent_t *, int, mode_t *); 2560Sstevel@tonic-gate extern int aclsort(int, int, aclent_t *); 2570Sstevel@tonic-gate extern char *acltotext(aclent_t *, int); 2580Sstevel@tonic-gate extern aclent_t *aclfromtext(char *, int *); 259789Sahrens extern void acl_free(acl_t *); 260789Sahrens extern int acl_get(const char *, int, acl_t **); 261789Sahrens extern int facl_get(int, int, acl_t **); 262789Sahrens extern int acl_set(const char *, acl_t *acl); 263789Sahrens extern int facl_set(int, acl_t *acl); 264789Sahrens extern int acl_strip(const char *, uid_t, gid_t, mode_t); 265789Sahrens extern int acl_trivial(const char *); 2661420Smarks extern char *acl_totext(acl_t *, int); 267789Sahrens extern int acl_fromtext(const char *, acl_t **); 268789Sahrens extern int acl_check(acl_t *, int); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate #else /* !defined(_KERNEL) */ 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate extern void ksort(caddr_t, int, int, int (*)(void *, void *)); 2730Sstevel@tonic-gate extern int cmp2acls(void *, void *); 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate #endif /* !defined(_KERNEL) */ 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate #if defined(__STDC__) 2780Sstevel@tonic-gate extern int acl(const char *path, int cmd, int cnt, void *buf); 2790Sstevel@tonic-gate extern int facl(int fd, int cmd, int cnt, void *buf); 2800Sstevel@tonic-gate #else /* !__STDC__ */ 2810Sstevel@tonic-gate extern int acl(); 2820Sstevel@tonic-gate extern int facl(); 2830Sstevel@tonic-gate #endif /* defined(__STDC__) */ 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate #ifdef __cplusplus 2860Sstevel@tonic-gate } 2870Sstevel@tonic-gate #endif 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate #endif /* _SYS_ACL_H */ 290