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