1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_ACL_H 28*0Sstevel@tonic-gate #define _SYS_ACL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/types.h> 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #ifdef __cplusplus 35*0Sstevel@tonic-gate extern "C" { 36*0Sstevel@tonic-gate #endif 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #define MAX_ACL_ENTRIES (1024) /* max entries of each type */ 39*0Sstevel@tonic-gate typedef struct acl { 40*0Sstevel@tonic-gate int a_type; /* the type of ACL entry */ 41*0Sstevel@tonic-gate uid_t a_id; /* the entry in -uid or gid */ 42*0Sstevel@tonic-gate o_mode_t a_perm; /* the permission field */ 43*0Sstevel@tonic-gate } aclent_t; 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate typedef struct ace { 46*0Sstevel@tonic-gate uid_t a_who; /* uid or gid */ 47*0Sstevel@tonic-gate uint32_t a_access_mask; /* "rwx" */ 48*0Sstevel@tonic-gate uint16_t a_flags; /* see below */ 49*0Sstevel@tonic-gate uint16_t a_type; /* allow or deny */ 50*0Sstevel@tonic-gate } ace_t; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate /* 53*0Sstevel@tonic-gate * The following are Defined types for an aclent_t. 54*0Sstevel@tonic-gate */ 55*0Sstevel@tonic-gate #define USER_OBJ (0x01) /* object owner */ 56*0Sstevel@tonic-gate #define USER (0x02) /* additional users */ 57*0Sstevel@tonic-gate #define GROUP_OBJ (0x04) /* owning group of the object */ 58*0Sstevel@tonic-gate #define GROUP (0x08) /* additional groups */ 59*0Sstevel@tonic-gate #define CLASS_OBJ (0x10) /* file group class and mask entry */ 60*0Sstevel@tonic-gate #define OTHER_OBJ (0x20) /* other entry for the object */ 61*0Sstevel@tonic-gate #define ACL_DEFAULT (0x1000) /* default flag */ 62*0Sstevel@tonic-gate /* default object owner */ 63*0Sstevel@tonic-gate #define DEF_USER_OBJ (ACL_DEFAULT | USER_OBJ) 64*0Sstevel@tonic-gate /* defalut additional users */ 65*0Sstevel@tonic-gate #define DEF_USER (ACL_DEFAULT | USER) 66*0Sstevel@tonic-gate /* default owning group */ 67*0Sstevel@tonic-gate #define DEF_GROUP_OBJ (ACL_DEFAULT | GROUP_OBJ) 68*0Sstevel@tonic-gate /* default additional groups */ 69*0Sstevel@tonic-gate #define DEF_GROUP (ACL_DEFAULT | GROUP) 70*0Sstevel@tonic-gate /* default mask entry */ 71*0Sstevel@tonic-gate #define DEF_CLASS_OBJ (ACL_DEFAULT | CLASS_OBJ) 72*0Sstevel@tonic-gate /* default other entry */ 73*0Sstevel@tonic-gate #define DEF_OTHER_OBJ (ACL_DEFAULT | OTHER_OBJ) 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* 76*0Sstevel@tonic-gate * The following are defined for ace_t. 77*0Sstevel@tonic-gate */ 78*0Sstevel@tonic-gate #define ACE_FILE_INHERIT_ACE 0x0001 79*0Sstevel@tonic-gate #define ACE_DIRECTORY_INHERIT_ACE 0x0002 80*0Sstevel@tonic-gate #define ACE_NO_PROPOGATE_INHERIT_ACE 0x0004 81*0Sstevel@tonic-gate #define ACE_INHERIT_ONLY_ACE 0x0008 82*0Sstevel@tonic-gate #define ACE_LOCALLY_DEFINED 0x0010 83*0Sstevel@tonic-gate #define ACE_OWNER 0x0100 /* file owner */ 84*0Sstevel@tonic-gate #define ACE_GROUP 0x0200 /* file group */ 85*0Sstevel@tonic-gate #define ACE_OTHER 0x0400 /* other field */ 86*0Sstevel@tonic-gate #define ACE_USER 0x0800 /* additional users */ 87*0Sstevel@tonic-gate #define ACE_GROUPS 0x1000 /* additional groups */ 88*0Sstevel@tonic-gate /* 89*0Sstevel@tonic-gate * The following flags are supported by both NFSv4 ACLs and ace_t. 90*0Sstevel@tonic-gate */ 91*0Sstevel@tonic-gate #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \ 92*0Sstevel@tonic-gate ACE_DIRECTORY_INHERIT_ACE | \ 93*0Sstevel@tonic-gate ACE_NO_PROPOGATE_INHERIT_ACE | \ 94*0Sstevel@tonic-gate ACE_INHERIT_ONLY_ACE) 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate #define ALLOW 0 97*0Sstevel@tonic-gate #define DENY 1 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate #define ACE_READ_DATA 04 /* 'r' */ 100*0Sstevel@tonic-gate #define ACE_WRITE_DATA 02 /* 'w' */ 101*0Sstevel@tonic-gate #define ACE_EXECUTE 01 /* 'x' */ 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate /* cmd args to acl(2) for aclent_t */ 104*0Sstevel@tonic-gate #define GETACL 1 105*0Sstevel@tonic-gate #define SETACL 2 106*0Sstevel@tonic-gate #define GETACLCNT 3 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* cmd's to manipulate ace acl's. */ 109*0Sstevel@tonic-gate #define ACE_GETACL 4 110*0Sstevel@tonic-gate #define ACE_SETACL 5 111*0Sstevel@tonic-gate #define ACE_GETACLCNT 6 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate /* minimal acl entries from GETACLCNT */ 114*0Sstevel@tonic-gate #define MIN_ACL_ENTRIES 4 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate #if !defined(_KERNEL) 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* acl check errors */ 119*0Sstevel@tonic-gate #define GRP_ERROR 1 120*0Sstevel@tonic-gate #define USER_ERROR 2 121*0Sstevel@tonic-gate #define OTHER_ERROR 3 122*0Sstevel@tonic-gate #define CLASS_ERROR 4 123*0Sstevel@tonic-gate #define DUPLICATE_ERROR 5 124*0Sstevel@tonic-gate #define MISS_ERROR 6 125*0Sstevel@tonic-gate #define MEM_ERROR 7 126*0Sstevel@tonic-gate #define ENTRY_ERROR 8 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate /* 129*0Sstevel@tonic-gate * similar to ufs_acl.h: changed to char type for user commands (tar, cpio) 130*0Sstevel@tonic-gate * Attribute types 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate #define UFSD_FREE ('0') /* Free entry */ 133*0Sstevel@tonic-gate #define UFSD_ACL ('1') /* Access Control Lists */ 134*0Sstevel@tonic-gate #define UFSD_DFACL ('2') /* reserved for future use */ 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate extern int aclcheck(aclent_t *, int, int *); 137*0Sstevel@tonic-gate extern int acltomode(aclent_t *, int, mode_t *); 138*0Sstevel@tonic-gate extern int aclfrommode(aclent_t *, int, mode_t *); 139*0Sstevel@tonic-gate extern int aclsort(int, int, aclent_t *); 140*0Sstevel@tonic-gate extern char *acltotext(aclent_t *, int); 141*0Sstevel@tonic-gate extern aclent_t *aclfromtext(char *, int *); 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate #else /* !defined(_KERNEL) */ 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate extern void ksort(caddr_t, int, int, int (*)(void *, void *)); 146*0Sstevel@tonic-gate extern int cmp2acls(void *, void *); 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate #endif /* !defined(_KERNEL) */ 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate #if defined(__STDC__) 151*0Sstevel@tonic-gate extern int acl(const char *path, int cmd, int cnt, void *buf); 152*0Sstevel@tonic-gate extern int facl(int fd, int cmd, int cnt, void *buf); 153*0Sstevel@tonic-gate #else /* !__STDC__ */ 154*0Sstevel@tonic-gate extern int acl(); 155*0Sstevel@tonic-gate extern int facl(); 156*0Sstevel@tonic-gate #endif /* defined(__STDC__) */ 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate #ifdef __cplusplus 159*0Sstevel@tonic-gate } 160*0Sstevel@tonic-gate #endif 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate #endif /* _SYS_ACL_H */ 163