1*9aa2a9c3Schristos /*- 2*9aa2a9c3Schristos * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*9aa2a9c3Schristos * 4*9aa2a9c3Schristos * Copyright (c) 1999-2001 Robert N. M. Watson 5*9aa2a9c3Schristos * Copyright (c) 2008 Edward Tomasz Napierała <trasz@FreeBSD.org> 6*9aa2a9c3Schristos * All rights reserved. 7*9aa2a9c3Schristos * 8*9aa2a9c3Schristos * This software was developed by Robert Watson for the TrustedBSD Project. 9*9aa2a9c3Schristos * 10*9aa2a9c3Schristos * Redistribution and use in source and binary forms, with or without 11*9aa2a9c3Schristos * modification, are permitted provided that the following conditions 12*9aa2a9c3Schristos * are met: 13*9aa2a9c3Schristos * 1. Redistributions of source code must retain the above copyright 14*9aa2a9c3Schristos * notice, this list of conditions and the following disclaimer. 15*9aa2a9c3Schristos * 2. Redistributions in binary form must reproduce the above copyright 16*9aa2a9c3Schristos * notice, this list of conditions and the following disclaimer in the 17*9aa2a9c3Schristos * documentation and/or other materials provided with the distribution. 18*9aa2a9c3Schristos * 19*9aa2a9c3Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20*9aa2a9c3Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21*9aa2a9c3Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22*9aa2a9c3Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23*9aa2a9c3Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24*9aa2a9c3Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25*9aa2a9c3Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26*9aa2a9c3Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27*9aa2a9c3Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28*9aa2a9c3Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29*9aa2a9c3Schristos * SUCH DAMAGE. 30*9aa2a9c3Schristos * 31*9aa2a9c3Schristos * $FreeBSD: head/sys/sys/acl.h 326256 2017-11-27 15:01:59Z pfg $ 32*9aa2a9c3Schristos */ 33*9aa2a9c3Schristos /* 34*9aa2a9c3Schristos * Developed by the TrustedBSD Project. 35*9aa2a9c3Schristos * Support for POSIX.1e and NFSv4 access control lists. 36*9aa2a9c3Schristos */ 37*9aa2a9c3Schristos 38*9aa2a9c3Schristos #ifndef _SYS_ACL_H_ 39*9aa2a9c3Schristos #define _SYS_ACL_H_ 40*9aa2a9c3Schristos 41*9aa2a9c3Schristos #include <sys/param.h> 42*9aa2a9c3Schristos #include <sys/queue.h> 43*9aa2a9c3Schristos 44*9aa2a9c3Schristos /* 45*9aa2a9c3Schristos * POSIX.1e and NFSv4 ACL types and related constants. 46*9aa2a9c3Schristos */ 47*9aa2a9c3Schristos 48*9aa2a9c3Schristos typedef uint32_t acl_tag_t; 49*9aa2a9c3Schristos typedef uint32_t acl_perm_t; 50*9aa2a9c3Schristos typedef uint16_t acl_entry_type_t; 51*9aa2a9c3Schristos typedef uint16_t acl_flag_t; 52*9aa2a9c3Schristos typedef int acl_type_t; 53*9aa2a9c3Schristos typedef uint32_t *acl_permset_t; 54*9aa2a9c3Schristos typedef uint16_t *acl_flagset_t; 55*9aa2a9c3Schristos 56*9aa2a9c3Schristos /* 57*9aa2a9c3Schristos * With 254 entries, "struct acl_t_struct" is exactly one 4kB page big. 58*9aa2a9c3Schristos * Note that with NFSv4 ACLs, the maximum number of ACL entries one 59*9aa2a9c3Schristos * may set on file or directory is about half of ACL_MAX_ENTRIES. 60*9aa2a9c3Schristos * 61*9aa2a9c3Schristos * If you increase this, you might also need to increase 62*9aa2a9c3Schristos * _ACL_T_ALIGNMENT_BITS in lib/libc/posix1e/acl_support.h. 63*9aa2a9c3Schristos * 64*9aa2a9c3Schristos * The maximum number of POSIX.1e ACLs is controlled 65*9aa2a9c3Schristos * by OLDACL_MAX_ENTRIES. Changing that one will break binary 66*9aa2a9c3Schristos * compatibility with pre-8.0 userland and change on-disk ACL layout. 67*9aa2a9c3Schristos */ 68*9aa2a9c3Schristos #define ACL_MAX_ENTRIES 254 69*9aa2a9c3Schristos 70*9aa2a9c3Schristos #if defined(_KERNEL) || defined(_ACL_PRIVATE) || defined(_MODULE) 71*9aa2a9c3Schristos 72*9aa2a9c3Schristos #define POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM 73*9aa2a9c3Schristos #define POSIX1E_ACL_ACCESS_EXTATTR_NAME "posix1e.acl_access" 74*9aa2a9c3Schristos #define POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM 75*9aa2a9c3Schristos #define POSIX1E_ACL_DEFAULT_EXTATTR_NAME "posix1e.acl_default" 76*9aa2a9c3Schristos #define NFS4_ACL_EXTATTR_NAMESPACE EXTATTR_NAMESPACE_SYSTEM 77*9aa2a9c3Schristos #define NFS4_ACL_EXTATTR_NAME "nfs4.acl" 78*9aa2a9c3Schristos #define OLDACL_MAX_ENTRIES 32 79*9aa2a9c3Schristos 80*9aa2a9c3Schristos /* 81*9aa2a9c3Schristos * "struct oldacl" is used in compatibility ACL syscalls and for on-disk 82*9aa2a9c3Schristos * storage of POSIX.1e ACLs. 83*9aa2a9c3Schristos */ 84*9aa2a9c3Schristos typedef int oldacl_tag_t; 85*9aa2a9c3Schristos typedef mode_t oldacl_perm_t; 86*9aa2a9c3Schristos 87*9aa2a9c3Schristos struct oldacl_entry { 88*9aa2a9c3Schristos oldacl_tag_t ae_tag; 89*9aa2a9c3Schristos uid_t ae_id; 90*9aa2a9c3Schristos oldacl_perm_t ae_perm; 91*9aa2a9c3Schristos }; 92*9aa2a9c3Schristos typedef struct oldacl_entry *oldacl_entry_t; 93*9aa2a9c3Schristos 94*9aa2a9c3Schristos struct oldacl { 95*9aa2a9c3Schristos int acl_cnt; 96*9aa2a9c3Schristos struct oldacl_entry acl_entry[OLDACL_MAX_ENTRIES]; 97*9aa2a9c3Schristos }; 98*9aa2a9c3Schristos 99*9aa2a9c3Schristos /* 100*9aa2a9c3Schristos * Current "struct acl". 101*9aa2a9c3Schristos */ 102*9aa2a9c3Schristos struct acl_entry { 103*9aa2a9c3Schristos acl_tag_t ae_tag; 104*9aa2a9c3Schristos uid_t ae_id; 105*9aa2a9c3Schristos acl_perm_t ae_perm; 106*9aa2a9c3Schristos /* NFSv4 entry type, "allow" or "deny". Unused in POSIX.1e ACLs. */ 107*9aa2a9c3Schristos acl_entry_type_t ae_entry_type; 108*9aa2a9c3Schristos /* NFSv4 ACL inheritance. Unused in POSIX.1e ACLs. */ 109*9aa2a9c3Schristos acl_flag_t ae_flags; 110*9aa2a9c3Schristos }; 111*9aa2a9c3Schristos typedef struct acl_entry *acl_entry_t; 112*9aa2a9c3Schristos 113*9aa2a9c3Schristos /* 114*9aa2a9c3Schristos * Internal ACL structure, used in libc, kernel APIs and for on-disk 115*9aa2a9c3Schristos * storage of NFSv4 ACLs. POSIX.1e ACLs use "struct oldacl" for on-disk 116*9aa2a9c3Schristos * storage. 117*9aa2a9c3Schristos */ 118*9aa2a9c3Schristos struct acl { 119*9aa2a9c3Schristos unsigned int acl_maxcnt; 120*9aa2a9c3Schristos unsigned int acl_cnt; 121*9aa2a9c3Schristos /* Will be required e.g. to implement NFSv4.1 ACL inheritance. */ 122*9aa2a9c3Schristos int acl_spare[4]; 123*9aa2a9c3Schristos struct acl_entry acl_entry[ACL_MAX_ENTRIES]; 124*9aa2a9c3Schristos }; 125*9aa2a9c3Schristos 126*9aa2a9c3Schristos /* 127*9aa2a9c3Schristos * ACL structure internal to libc. 128*9aa2a9c3Schristos */ 129*9aa2a9c3Schristos struct acl_t_struct { 130*9aa2a9c3Schristos struct acl ats_acl; 131*9aa2a9c3Schristos unsigned int ats_cur_entry; 132*9aa2a9c3Schristos /* 133*9aa2a9c3Schristos * ats_brand is for libc internal bookkeeping only. 134*9aa2a9c3Schristos * Applications should use acl_get_brand_np(3). 135*9aa2a9c3Schristos * Kernel code should use the "type" argument passed 136*9aa2a9c3Schristos * to VOP_SETACL, VOP_GETACL or VOP_ACLCHECK calls; 137*9aa2a9c3Schristos * ACL_TYPE_ACCESS or ACL_TYPE_DEFAULT mean POSIX.1e 138*9aa2a9c3Schristos * ACL, ACL_TYPE_NFS4 means NFSv4 ACL. 139*9aa2a9c3Schristos */ 140*9aa2a9c3Schristos int ats_brand; 141*9aa2a9c3Schristos }; 142*9aa2a9c3Schristos typedef struct acl_t_struct *acl_t; 143*9aa2a9c3Schristos 144*9aa2a9c3Schristos #else /* _KERNEL || _ACL_PRIVATE */ 145*9aa2a9c3Schristos 146*9aa2a9c3Schristos typedef void *acl_entry_t; 147*9aa2a9c3Schristos typedef void *acl_t; 148*9aa2a9c3Schristos 149*9aa2a9c3Schristos #endif /* !_KERNEL && !_ACL_PRIVATE */ 150*9aa2a9c3Schristos 151*9aa2a9c3Schristos /* 152*9aa2a9c3Schristos * Possible valid values for ats_brand field. 153*9aa2a9c3Schristos */ 154*9aa2a9c3Schristos #define ACL_BRAND_UNKNOWN 0 155*9aa2a9c3Schristos #define ACL_BRAND_POSIX 1 156*9aa2a9c3Schristos #define ACL_BRAND_NFS4 2 157*9aa2a9c3Schristos 158*9aa2a9c3Schristos /* 159*9aa2a9c3Schristos * Possible valid values for ae_tag field. For explanation, see acl(9). 160*9aa2a9c3Schristos */ 161*9aa2a9c3Schristos #define ACL_UNDEFINED_TAG 0x00000000 162*9aa2a9c3Schristos #define ACL_USER_OBJ 0x00000001 163*9aa2a9c3Schristos #define ACL_USER 0x00000002 164*9aa2a9c3Schristos #define ACL_GROUP_OBJ 0x00000004 165*9aa2a9c3Schristos #define ACL_GROUP 0x00000008 166*9aa2a9c3Schristos #define ACL_MASK 0x00000010 167*9aa2a9c3Schristos #define ACL_OTHER 0x00000020 168*9aa2a9c3Schristos #define ACL_OTHER_OBJ ACL_OTHER 169*9aa2a9c3Schristos #define ACL_EVERYONE 0x00000040 170*9aa2a9c3Schristos 171*9aa2a9c3Schristos /* 172*9aa2a9c3Schristos * Possible valid values for ae_entry_type field, valid only for NFSv4 ACLs. 173*9aa2a9c3Schristos */ 174*9aa2a9c3Schristos #define ACL_ENTRY_TYPE_ALLOW 0x0100 175*9aa2a9c3Schristos #define ACL_ENTRY_TYPE_DENY 0x0200 176*9aa2a9c3Schristos #define ACL_ENTRY_TYPE_AUDIT 0x0400 177*9aa2a9c3Schristos #define ACL_ENTRY_TYPE_ALARM 0x0800 178*9aa2a9c3Schristos 179*9aa2a9c3Schristos /* 180*9aa2a9c3Schristos * Possible valid values for acl_type_t arguments. First two 181*9aa2a9c3Schristos * are provided only for backwards binary compatibility. 182*9aa2a9c3Schristos */ 183*9aa2a9c3Schristos #define ACL_TYPE_ACCESS_OLD 0x00000000 184*9aa2a9c3Schristos #define ACL_TYPE_DEFAULT_OLD 0x00000001 185*9aa2a9c3Schristos #define ACL_TYPE_ACCESS 0x00000002 186*9aa2a9c3Schristos #define ACL_TYPE_DEFAULT 0x00000003 187*9aa2a9c3Schristos #define ACL_TYPE_NFS4 0x00000004 188*9aa2a9c3Schristos 189*9aa2a9c3Schristos /* 190*9aa2a9c3Schristos * Possible bits in ae_perm field for POSIX.1e ACLs. Note 191*9aa2a9c3Schristos * that ACL_EXECUTE may be used in both NFSv4 and POSIX.1e ACLs. 192*9aa2a9c3Schristos */ 193*9aa2a9c3Schristos #define ACL_EXECUTE 0x0001 194*9aa2a9c3Schristos #define ACL_WRITE 0x0002 195*9aa2a9c3Schristos #define ACL_READ 0x0004 196*9aa2a9c3Schristos #define ACL_PERM_NONE 0x0000 197*9aa2a9c3Schristos #define ACL_PERM_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) 198*9aa2a9c3Schristos #define ACL_POSIX1E_BITS (ACL_EXECUTE | ACL_WRITE | ACL_READ) 199*9aa2a9c3Schristos 200*9aa2a9c3Schristos /* 201*9aa2a9c3Schristos * Possible bits in ae_perm field for NFSv4 ACLs. 202*9aa2a9c3Schristos */ 203*9aa2a9c3Schristos #define ACL_READ_DATA 0x00000008 204*9aa2a9c3Schristos #define ACL_LIST_DIRECTORY 0x00000008 205*9aa2a9c3Schristos #define ACL_WRITE_DATA 0x00000010 206*9aa2a9c3Schristos #define ACL_ADD_FILE 0x00000010 207*9aa2a9c3Schristos #define ACL_APPEND_DATA 0x00000020 208*9aa2a9c3Schristos #define ACL_ADD_SUBDIRECTORY 0x00000020 209*9aa2a9c3Schristos #define ACL_READ_NAMED_ATTRS 0x00000040 210*9aa2a9c3Schristos #define ACL_WRITE_NAMED_ATTRS 0x00000080 211*9aa2a9c3Schristos /* ACL_EXECUTE is defined above. */ 212*9aa2a9c3Schristos #define ACL_DELETE_CHILD 0x00000100 213*9aa2a9c3Schristos #define ACL_READ_ATTRIBUTES 0x00000200 214*9aa2a9c3Schristos #define ACL_WRITE_ATTRIBUTES 0x00000400 215*9aa2a9c3Schristos #define ACL_DELETE 0x00000800 216*9aa2a9c3Schristos #define ACL_READ_ACL 0x00001000 217*9aa2a9c3Schristos #define ACL_WRITE_ACL 0x00002000 218*9aa2a9c3Schristos #define ACL_WRITE_OWNER 0x00004000 219*9aa2a9c3Schristos #define ACL_SYNCHRONIZE 0x00008000 220*9aa2a9c3Schristos 221*9aa2a9c3Schristos #define ACL_FULL_SET (ACL_READ_DATA | ACL_WRITE_DATA | \ 222*9aa2a9c3Schristos ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \ 223*9aa2a9c3Schristos ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \ 224*9aa2a9c3Schristos ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \ 225*9aa2a9c3Schristos ACL_WRITE_OWNER | ACL_SYNCHRONIZE) 226*9aa2a9c3Schristos 227*9aa2a9c3Schristos #define ACL_MODIFY_SET (ACL_FULL_SET & \ 228*9aa2a9c3Schristos ~(ACL_WRITE_ACL | ACL_WRITE_OWNER)) 229*9aa2a9c3Schristos 230*9aa2a9c3Schristos #define ACL_READ_SET (ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \ 231*9aa2a9c3Schristos ACL_READ_ATTRIBUTES | ACL_READ_ACL) 232*9aa2a9c3Schristos 233*9aa2a9c3Schristos #define ACL_WRITE_SET (ACL_WRITE_DATA | ACL_APPEND_DATA | \ 234*9aa2a9c3Schristos ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES) 235*9aa2a9c3Schristos 236*9aa2a9c3Schristos #define ACL_NFS4_PERM_BITS ACL_FULL_SET 237*9aa2a9c3Schristos 238*9aa2a9c3Schristos /* 239*9aa2a9c3Schristos * Possible entry_id values for acl_get_entry(3). 240*9aa2a9c3Schristos */ 241*9aa2a9c3Schristos #define ACL_FIRST_ENTRY 0 242*9aa2a9c3Schristos #define ACL_NEXT_ENTRY 1 243*9aa2a9c3Schristos 244*9aa2a9c3Schristos /* 245*9aa2a9c3Schristos * Possible values in ae_flags field; valid only for NFSv4 ACLs. 246*9aa2a9c3Schristos */ 247*9aa2a9c3Schristos #define ACL_ENTRY_FILE_INHERIT 0x0001 248*9aa2a9c3Schristos #define ACL_ENTRY_DIRECTORY_INHERIT 0x0002 249*9aa2a9c3Schristos #define ACL_ENTRY_NO_PROPAGATE_INHERIT 0x0004 250*9aa2a9c3Schristos #define ACL_ENTRY_INHERIT_ONLY 0x0008 251*9aa2a9c3Schristos #define ACL_ENTRY_SUCCESSFUL_ACCESS 0x0010 252*9aa2a9c3Schristos #define ACL_ENTRY_FAILED_ACCESS 0x0020 253*9aa2a9c3Schristos #define ACL_ENTRY_INHERITED 0x0080 254*9aa2a9c3Schristos 255*9aa2a9c3Schristos #define ACL_FLAGS_BITS (ACL_ENTRY_FILE_INHERIT | \ 256*9aa2a9c3Schristos ACL_ENTRY_DIRECTORY_INHERIT | ACL_ENTRY_NO_PROPAGATE_INHERIT | \ 257*9aa2a9c3Schristos ACL_ENTRY_INHERIT_ONLY | ACL_ENTRY_SUCCESSFUL_ACCESS | \ 258*9aa2a9c3Schristos ACL_ENTRY_FAILED_ACCESS | ACL_ENTRY_INHERITED) 259*9aa2a9c3Schristos 260*9aa2a9c3Schristos /* 261*9aa2a9c3Schristos * Undefined value in ae_id field. ae_id should be set to this value 262*9aa2a9c3Schristos * iff ae_tag is ACL_USER_OBJ, ACL_GROUP_OBJ, ACL_OTHER or ACL_EVERYONE. 263*9aa2a9c3Schristos */ 264*9aa2a9c3Schristos #define ACL_UNDEFINED_ID ((uid_t)-1) 265*9aa2a9c3Schristos 266*9aa2a9c3Schristos /* 267*9aa2a9c3Schristos * Possible values for _flags parameter in acl_to_text_np(3). 268*9aa2a9c3Schristos */ 269*9aa2a9c3Schristos #define ACL_TEXT_VERBOSE 0x01 270*9aa2a9c3Schristos #define ACL_TEXT_NUMERIC_IDS 0x02 271*9aa2a9c3Schristos #define ACL_TEXT_APPEND_ID 0x04 272*9aa2a9c3Schristos 273*9aa2a9c3Schristos /* 274*9aa2a9c3Schristos * POSIX.1e ACLs are capable of expressing the read, write, and execute bits 275*9aa2a9c3Schristos * of the POSIX mode field. We provide two masks: one that defines the bits 276*9aa2a9c3Schristos * the ACL will replace in the mode, and the other that defines the bits that 277*9aa2a9c3Schristos * must be preseved when an ACL is updating a mode. 278*9aa2a9c3Schristos */ 279*9aa2a9c3Schristos #define ACL_OVERRIDE_MASK (S_IRWXU | S_IRWXG | S_IRWXO) 280*9aa2a9c3Schristos #define ACL_PRESERVE_MASK (~ACL_OVERRIDE_MASK) 281*9aa2a9c3Schristos 282*9aa2a9c3Schristos #ifdef _KERNEL 283*9aa2a9c3Schristos 284*9aa2a9c3Schristos /* 285*9aa2a9c3Schristos * Filesystem-independent code to move back and forth between POSIX mode and 286*9aa2a9c3Schristos * POSIX.1e ACL representations. 287*9aa2a9c3Schristos */ 288*9aa2a9c3Schristos acl_perm_t acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode); 289*9aa2a9c3Schristos struct acl_entry acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid, 290*9aa2a9c3Schristos gid_t gid, mode_t mode); 291*9aa2a9c3Schristos mode_t acl_posix1e_perms_to_mode( 292*9aa2a9c3Schristos struct acl_entry *acl_user_obj_entry, 293*9aa2a9c3Schristos struct acl_entry *acl_group_obj_entry, 294*9aa2a9c3Schristos struct acl_entry *acl_other_entry); 295*9aa2a9c3Schristos mode_t acl_posix1e_acl_to_mode(struct acl *acl); 296*9aa2a9c3Schristos mode_t acl_posix1e_newfilemode(mode_t cmode, 297*9aa2a9c3Schristos struct acl *dacl); 298*9aa2a9c3Schristos struct acl *acl_alloc(int flags); 299*9aa2a9c3Schristos void acl_free(struct acl *aclp); 300*9aa2a9c3Schristos 301*9aa2a9c3Schristos void acl_nfs4_sync_acl_from_mode(struct acl *aclp, 302*9aa2a9c3Schristos mode_t mode, int file_owner_id); 303*9aa2a9c3Schristos void __acl_nfs4_sync_mode_from_acl(mode_t *mode, 304*9aa2a9c3Schristos const struct acl *aclp); 305*9aa2a9c3Schristos int acl_nfs4_is_trivial(const struct acl *aclp, 306*9aa2a9c3Schristos int file_owner_id); 307*9aa2a9c3Schristos void acl_nfs4_compute_inherited_acl( 308*9aa2a9c3Schristos const struct acl *parent_aclp, 309*9aa2a9c3Schristos struct acl *child_aclp, mode_t mode, 310*9aa2a9c3Schristos int file_owner_id, int is_directory); 311*9aa2a9c3Schristos int acl_copy_oldacl_into_acl(const struct oldacl *source, 312*9aa2a9c3Schristos struct acl *dest); 313*9aa2a9c3Schristos int acl_copy_acl_into_oldacl(const struct acl *source, 314*9aa2a9c3Schristos struct oldacl *dest); 315*9aa2a9c3Schristos 316*9aa2a9c3Schristos /* 317*9aa2a9c3Schristos * Filesystem-independent syntax check for a POSIX.1e ACL. 318*9aa2a9c3Schristos */ 319*9aa2a9c3Schristos int acl_posix1e_check(struct acl *acl); 320*9aa2a9c3Schristos int acl_nfs4_check(const struct acl *aclp, int is_directory); 321*9aa2a9c3Schristos 322*9aa2a9c3Schristos /* for compat32 */ 323*9aa2a9c3Schristos #include <sys/namei.h> 324*9aa2a9c3Schristos 325*9aa2a9c3Schristos int kern___acl_aclcheck_path(struct lwp *, const char *, acl_type_t, 326*9aa2a9c3Schristos struct acl *, namei_simple_flags_t); 327*9aa2a9c3Schristos int kern___acl_delete_path(struct lwp *, const char *, acl_type_t, 328*9aa2a9c3Schristos namei_simple_flags_t); 329*9aa2a9c3Schristos int kern___acl_get_path(struct lwp *, const char *, acl_type_t, 330*9aa2a9c3Schristos struct acl *, namei_simple_flags_t); 331*9aa2a9c3Schristos int kern___acl_set_path(struct lwp *, const char *, acl_type_t, 332*9aa2a9c3Schristos const struct acl *, namei_simple_flags_t); 333*9aa2a9c3Schristos int vacl_set_acl(struct lwp *, struct vnode *, acl_type_t, 334*9aa2a9c3Schristos const struct acl *); 335*9aa2a9c3Schristos int vacl_get_acl(struct lwp *, struct vnode *, acl_type_t, struct acl *); 336*9aa2a9c3Schristos int vacl_aclcheck(struct lwp *, struct vnode *, acl_type_t, 337*9aa2a9c3Schristos const struct acl *); 338*9aa2a9c3Schristos int vacl_delete(struct lwp *, struct vnode *, acl_type_t); 339*9aa2a9c3Schristos 340*9aa2a9c3Schristos #else /* !_KERNEL */ 341*9aa2a9c3Schristos 342*9aa2a9c3Schristos #if defined(_ACL_PRIVATE) 343*9aa2a9c3Schristos 344*9aa2a9c3Schristos /* 345*9aa2a9c3Schristos * Syscall interface -- use the library calls instead as the syscalls have 346*9aa2a9c3Schristos * strict ACL entry ordering requirements. 347*9aa2a9c3Schristos */ 348*9aa2a9c3Schristos __BEGIN_DECLS 349*9aa2a9c3Schristos int __acl_aclcheck_fd(int _filedes, acl_type_t _type, struct acl *_aclp); 350*9aa2a9c3Schristos int __acl_aclcheck_file(const char *_path, acl_type_t _type, 351*9aa2a9c3Schristos struct acl *_aclp); 352*9aa2a9c3Schristos int __acl_aclcheck_link(const char *_path, acl_type_t _type, 353*9aa2a9c3Schristos struct acl *_aclp); 354*9aa2a9c3Schristos int __acl_delete_fd(int _filedes, acl_type_t _type); 355*9aa2a9c3Schristos int __acl_delete_file(const char *_path_p, acl_type_t _type); 356*9aa2a9c3Schristos int __acl_delete_link(const char *_path_p, acl_type_t _type); 357*9aa2a9c3Schristos int __acl_get_fd(int _filedes, acl_type_t _type, struct acl *_aclp); 358*9aa2a9c3Schristos int __acl_get_file(const char *_path, acl_type_t _type, struct acl *_aclp); 359*9aa2a9c3Schristos int __acl_get_link(const char *_path, acl_type_t _type, struct acl *_aclp); 360*9aa2a9c3Schristos int __acl_set_fd(int _filedes, acl_type_t _type, struct acl *_aclp); 361*9aa2a9c3Schristos int __acl_set_file(const char *_path, acl_type_t _type, struct acl *_aclp); 362*9aa2a9c3Schristos int __acl_set_link(const char *_path, acl_type_t _type, struct acl *_aclp); 363*9aa2a9c3Schristos 364*9aa2a9c3Schristos /* 365*9aa2a9c3Schristos * These routines from sys/kern/subr_acl_nfs4.c are used by both kernel 366*9aa2a9c3Schristos * and libc. 367*9aa2a9c3Schristos */ 368*9aa2a9c3Schristos void __acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *_aclp); 369*9aa2a9c3Schristos void __acl_nfs4_trivial_from_mode_libc(struct acl *_aclp, int _file_owner_id, 370*9aa2a9c3Schristos int _canonical_six); 371*9aa2a9c3Schristos __END_DECLS 372*9aa2a9c3Schristos 373*9aa2a9c3Schristos #endif /* _ACL_PRIVATE */ 374*9aa2a9c3Schristos 375*9aa2a9c3Schristos /* 376*9aa2a9c3Schristos * Supported POSIX.1e ACL manipulation and assignment/retrieval API _np calls 377*9aa2a9c3Schristos * are local extensions that reflect an environment capable of opening file 378*9aa2a9c3Schristos * descriptors of directories, and allowing additional ACL type for different 379*9aa2a9c3Schristos * filesystems (i.e., AFS). 380*9aa2a9c3Schristos */ 381*9aa2a9c3Schristos __BEGIN_DECLS 382*9aa2a9c3Schristos int acl_add_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); 383*9aa2a9c3Schristos int acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm); 384*9aa2a9c3Schristos int acl_calc_mask(acl_t *_acl_p); 385*9aa2a9c3Schristos int acl_clear_flags_np(acl_flagset_t _flagset_d); 386*9aa2a9c3Schristos int acl_clear_perms(acl_permset_t _permset_d); 387*9aa2a9c3Schristos int acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d); 388*9aa2a9c3Schristos ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size); 389*9aa2a9c3Schristos acl_t acl_copy_int(const void *_buf_p); 390*9aa2a9c3Schristos int acl_create_entry(acl_t *_acl_p, acl_entry_t *_entry_p); 391*9aa2a9c3Schristos int acl_create_entry_np(acl_t *_acl_p, acl_entry_t *_entry_p, int _index); 392*9aa2a9c3Schristos int acl_delete_entry(acl_t _acl, acl_entry_t _entry_d); 393*9aa2a9c3Schristos int acl_delete_entry_np(acl_t _acl, int _index); 394*9aa2a9c3Schristos int acl_delete_fd_np(int _filedes, acl_type_t _type); 395*9aa2a9c3Schristos int acl_delete_file_np(const char *_path_p, acl_type_t _type); 396*9aa2a9c3Schristos int acl_delete_link_np(const char *_path_p, acl_type_t _type); 397*9aa2a9c3Schristos int acl_delete_def_file(const char *_path_p); 398*9aa2a9c3Schristos int acl_delete_def_link_np(const char *_path_p); 399*9aa2a9c3Schristos int acl_delete_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); 400*9aa2a9c3Schristos int acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm); 401*9aa2a9c3Schristos acl_t acl_dup(acl_t _acl); 402*9aa2a9c3Schristos int acl_free(void *_obj_p); 403*9aa2a9c3Schristos acl_t acl_from_text(const char *_buf_p); 404*9aa2a9c3Schristos int acl_get_brand_np(acl_t _acl, int *_brand_p); 405*9aa2a9c3Schristos int acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p); 406*9aa2a9c3Schristos acl_t acl_get_fd(int _fd); 407*9aa2a9c3Schristos acl_t acl_get_fd_np(int fd, acl_type_t _type); 408*9aa2a9c3Schristos acl_t acl_get_file(const char *_path_p, acl_type_t _type); 409*9aa2a9c3Schristos int acl_get_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t *_entry_type_p); 410*9aa2a9c3Schristos acl_t acl_get_link_np(const char *_path_p, acl_type_t _type); 411*9aa2a9c3Schristos void *acl_get_qualifier(acl_entry_t _entry_d); 412*9aa2a9c3Schristos int acl_get_flag_np(acl_flagset_t _flagset_d, acl_flag_t _flag); 413*9aa2a9c3Schristos int acl_get_perm_np(acl_permset_t _permset_d, acl_perm_t _perm); 414*9aa2a9c3Schristos int acl_get_flagset_np(acl_entry_t _entry_d, acl_flagset_t *_flagset_p); 415*9aa2a9c3Schristos int acl_get_permset(acl_entry_t _entry_d, acl_permset_t *_permset_p); 416*9aa2a9c3Schristos int acl_get_tag_type(acl_entry_t _entry_d, acl_tag_t *_tag_type_p); 417*9aa2a9c3Schristos acl_t acl_init(int _count); 418*9aa2a9c3Schristos int acl_set_fd(int _fd, acl_t _acl); 419*9aa2a9c3Schristos int acl_set_fd_np(int _fd, acl_t _acl, acl_type_t _type); 420*9aa2a9c3Schristos int acl_set_file(const char *_path_p, acl_type_t _type, acl_t _acl); 421*9aa2a9c3Schristos int acl_set_entry_type_np(acl_entry_t _entry_d, acl_entry_type_t _entry_type); 422*9aa2a9c3Schristos int acl_set_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); 423*9aa2a9c3Schristos int acl_set_flagset_np(acl_entry_t _entry_d, acl_flagset_t _flagset_d); 424*9aa2a9c3Schristos int acl_set_permset(acl_entry_t _entry_d, acl_permset_t _permset_d); 425*9aa2a9c3Schristos int acl_set_qualifier(acl_entry_t _entry_d, const void *_tag_qualifier_p); 426*9aa2a9c3Schristos int acl_set_tag_type(acl_entry_t _entry_d, acl_tag_t _tag_type); 427*9aa2a9c3Schristos ssize_t acl_size(acl_t _acl); 428*9aa2a9c3Schristos char *acl_to_text(acl_t _acl, ssize_t *_len_p); 429*9aa2a9c3Schristos char *acl_to_text_np(acl_t _acl, ssize_t *_len_p, int _flags); 430*9aa2a9c3Schristos int acl_valid(acl_t _acl); 431*9aa2a9c3Schristos int acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl); 432*9aa2a9c3Schristos int acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl); 433*9aa2a9c3Schristos int acl_valid_link_np(const char *_path_p, acl_type_t _type, acl_t _acl); 434*9aa2a9c3Schristos int acl_is_trivial_np(const acl_t _acl, int *_trivialp); 435*9aa2a9c3Schristos acl_t acl_strip_np(const acl_t _acl, int recalculate_mask); 436*9aa2a9c3Schristos __END_DECLS 437*9aa2a9c3Schristos 438*9aa2a9c3Schristos #endif /* !_KERNEL */ 439*9aa2a9c3Schristos 440*9aa2a9c3Schristos #endif /* !_SYS_ACL_H_ */ 441