1 /*- 2 * Copyright (c) 1999, 2000 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: src/sys/sys/acl.h,v 1.8 2000/01/28 15:22:51 rwatson Exp $ 27 * $DragonFly: src/sys/sys/acl.h,v 1.5 2007/02/19 00:51:54 swildner Exp $ 28 */ 29 30 /* 31 * Userland/kernel interface for Access Control Lists. 32 * 33 * The POSIX.1e implementation page may be reached at: 34 * http://www.watson.org/fbsd-hardening/posix1e/ 35 */ 36 37 #ifndef _SYS_ACL_H_ 38 #define _SYS_ACL_H_ 39 40 #ifndef _SYS_TYPES_H_ 41 #include <sys/types.h> 42 #endif 43 44 /* 45 * POSIX.1e ACL types and related constants 46 */ 47 48 #define ACL_MAX_ENTRIES 32 /* maximum entries in an ACL */ 49 #define _POSIX_ACL_PATH_MAX ACL_MAX_ENTRIES 50 51 typedef int acl_type_t; 52 typedef int acl_tag_t; 53 typedef mode_t acl_perm_t; 54 55 struct acl_entry { 56 acl_tag_t ae_tag; 57 uid_t ae_id; 58 acl_perm_t ae_perm; 59 }; 60 typedef struct acl_entry *acl_entry_t; 61 62 struct acl { 63 int acl_cnt; 64 struct acl_entry acl_entry[ACL_MAX_ENTRIES]; 65 }; 66 typedef struct acl *acl_t; 67 68 /* 69 * Possible valid values for a_tag of acl_entry_t 70 */ 71 #define ACL_USER_OBJ 0x00000001 72 #define ACL_USER 0x00000002 73 #define ACL_GROUP_OBJ 0x00000004 74 #define ACL_GROUP 0x00000008 75 #define ACL_MASK 0x00000010 76 #define ACL_OTHER 0x00000020 77 #define ACL_OTHER_OBJ ACL_OTHER 78 79 /* 80 * Possible valid values a_type_t arguments 81 */ 82 #define ACL_TYPE_ACCESS 0x00000000 83 #define ACL_TYPE_DEFAULT 0x00000001 84 #define ACL_TYPE_AFS 0x00000002 85 #define ACL_TYPE_CODA 0x00000003 86 #define ACL_TYPE_NTFS 0x00000004 87 #define ACL_TYPE_NWFS 0x00000005 88 89 /* 90 * Possible flags in a_perm field 91 */ 92 #define ACL_PERM_EXEC 0x0001 93 #define ACL_PERM_WRITE 0x0002 94 #define ACL_PERM_READ 0x0004 95 #define ACL_PERM_NONE 0x0000 96 #define ACL_PERM_BITS (ACL_PERM_EXEC | ACL_PERM_WRITE | ACL_PERM_READ) 97 #define ACL_POSIX1E_BITS (ACL_PERM_EXEC | ACL_PERM_WRITE | ACL_PERM_READ) 98 99 #ifndef _KERNEL 100 101 /* 102 * Syscall interface -- use the library calls instead as the syscalls 103 * have strict acl entry ordering requirements 104 */ 105 __BEGIN_DECLS 106 int __acl_aclcheck_fd(int, acl_type_t, struct acl *); 107 int __acl_aclcheck_file(const char *, acl_type_t, struct acl *); 108 int __acl_delete_fd(int, acl_type_t); 109 int __acl_delete_file(const char *, acl_type_t); 110 int __acl_get_fd(int, acl_type_t, struct acl *); 111 int __acl_get_file(const char *, acl_type_t, struct acl *); 112 int __acl_set_fd(int, acl_type_t, struct acl *); 113 int __acl_set_file(const char *, acl_type_t, struct acl *); 114 __END_DECLS 115 116 /* 117 * Supported POSIX.1e ACL manipulation and assignment/retrieval API 118 * _np calls are local extensions that reflect an environment capable of 119 * opening file descriptors of directories, and allowing additional 120 * ACL type for different file systems (i.e., AFS) 121 */ 122 __BEGIN_DECLS 123 int acl_delete_fd_np(int, acl_type_t); 124 int acl_delete_file_np(const char *, acl_type_t); 125 int acl_delete_def_file(const char *); 126 acl_t acl_dup(acl_t); 127 int acl_free(void *); 128 acl_t acl_from_text(const char *); 129 acl_t acl_get_fd(int); 130 acl_t acl_get_fd_np(int, acl_type_t); 131 acl_t acl_get_file(const char *, acl_type_t); 132 acl_t acl_init(int); 133 int acl_set_fd(int, acl_t); 134 int acl_set_fd_np(int, acl_t, acl_type_t); 135 int acl_set_file(const char *, acl_type_t, acl_t); 136 char *acl_to_text(acl_t, ssize_t *); 137 int acl_valid(acl_t); 138 int acl_valid_fd_np(int, acl_type_t, acl_t); 139 int acl_valid_file_np(const char *, acl_type_t, acl_t); 140 __END_DECLS 141 142 #endif /* !_KERNEL */ 143 144 #endif /* !_SYS_ACL_H_ */ 145