The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/acl.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999-2001 Robert N. M. Watson
    3  * All rights reserved.
    4  *
    5  * This software was developed by Robert Watson for the TrustedBSD Project.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  * $FreeBSD$
   29  */
   30 /* 
   31  * Developed by the TrustedBSD Project.
   32  * Support for POSIX.1e access control lists.
   33  */
   34 
   35 #ifndef _SYS_ACL_H_
   36 #define _SYS_ACL_H_
   37 
   38 #include <sys/param.h>
   39 #include <sys/queue.h>
   40 #include <vm/uma.h>
   41 
   42 /*
   43  * POSIX.1e ACL types and related constants.
   44  */
   45 
   46 #define POSIX1E_ACL_ACCESS_EXTATTR_NAMESPACE    EXTATTR_NAMESPACE_SYSTEM
   47 #define POSIX1E_ACL_ACCESS_EXTATTR_NAME         "posix1e.acl_access"
   48 #define POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE   EXTATTR_NAMESPACE_SYSTEM
   49 #define POSIX1E_ACL_DEFAULT_EXTATTR_NAME        "posix1e.acl_default"
   50 #define ACL_MAX_ENTRIES         32 /* maximum entries in an ACL */
   51 
   52 typedef int     acl_type_t;
   53 typedef int     acl_tag_t;
   54 typedef mode_t  acl_perm_t;
   55 typedef mode_t *acl_permset_t;
   56 
   57 struct acl_entry {
   58         acl_tag_t       ae_tag;
   59         uid_t           ae_id;
   60         acl_perm_t      ae_perm;
   61 };
   62 typedef struct acl_entry        *acl_entry_t;
   63 
   64 /* internal ACL structure */
   65 struct acl {
   66         int                     acl_cnt;
   67         struct acl_entry        acl_entry[ACL_MAX_ENTRIES];
   68 };
   69 
   70 /* external ACL structure */
   71 struct acl_t_struct {
   72         struct acl              ats_acl;
   73         int                     ats_cur_entry;
   74 };
   75 typedef struct acl_t_struct *acl_t;
   76 
   77 /*
   78  * Possible valid values for ae_tag field.
   79  */
   80 #define ACL_UNDEFINED_TAG       0x00000000
   81 #define ACL_USER_OBJ            0x00000001
   82 #define ACL_USER                0x00000002
   83 #define ACL_GROUP_OBJ           0x00000004
   84 #define ACL_GROUP               0x00000008
   85 #define ACL_MASK                0x00000010
   86 #define ACL_OTHER               0x00000020
   87 #define ACL_OTHER_OBJ           ACL_OTHER
   88 
   89 /*
   90  * Possible valid values for acl_type_t arguments.
   91  */
   92 #define ACL_TYPE_ACCESS         0x00000000
   93 #define ACL_TYPE_DEFAULT        0x00000001
   94 
   95 /*
   96  * Possible flags in ae_perm field.
   97  */
   98 #define ACL_EXECUTE             0x0001
   99 #define ACL_WRITE               0x0002
  100 #define ACL_READ                0x0004
  101 #define ACL_PERM_NONE           0x0000
  102 #define ACL_PERM_BITS           (ACL_EXECUTE | ACL_WRITE | ACL_READ)
  103 #define ACL_POSIX1E_BITS        (ACL_EXECUTE | ACL_WRITE | ACL_READ)
  104 
  105 /*
  106  * Possible entry_id values for acl_get_entry()
  107  */
  108 #define ACL_FIRST_ENTRY         0
  109 #define ACL_NEXT_ENTRY          1
  110 
  111 /*
  112  * Undefined value in ae_id field
  113  */
  114 #define ACL_UNDEFINED_ID        ((uid_t)-1)
  115 
  116 
  117 #ifdef _KERNEL
  118 
  119 extern uma_zone_t       acl_zone;
  120 
  121 /*
  122  * POSIX.1e ACLs are capable of expressing the read, write, and execute bits
  123  * of the POSIX mode field.  We provide two masks: one that defines the bits
  124  * the ACL will replace in the mode, and the other that defines the bits that
  125  * must be preseved when an ACL is updating a mode.
  126  */
  127 #define ACL_OVERRIDE_MASK       (S_IRWXU | S_IRWXG | S_IRWXO)
  128 #define ACL_PRESERVE_MASK       (~ACL_OVERRIDE_MASK)
  129 
  130 /*
  131  * File system independent code to move back and forth between POSIX mode and
  132  * POSIX.1e ACL representations.
  133  */
  134 acl_perm_t              acl_posix1e_mode_to_perm(acl_tag_t tag, mode_t mode);
  135 struct acl_entry        acl_posix1e_mode_to_entry(acl_tag_t tag, uid_t uid,
  136                             gid_t gid, mode_t mode);
  137 mode_t                  acl_posix1e_perms_to_mode(
  138                             struct acl_entry *acl_user_obj_entry,
  139                             struct acl_entry *acl_group_obj_entry,
  140                             struct acl_entry *acl_other_entry);
  141 mode_t                  acl_posix1e_acl_to_mode(struct acl *acl);
  142 mode_t                  acl_posix1e_newfilemode(mode_t cmode,
  143                             struct acl *dacl);
  144 
  145 /*
  146  * File system independent syntax check for a POSIX.1e ACL.
  147  */
  148 int                     acl_posix1e_check(struct acl *acl);
  149 
  150 #else /* !_KERNEL */
  151 
  152 /*
  153  * Syscall interface -- use the library calls instead as the syscalls have
  154  * strict acl entry ordering requirements.
  155  */
  156 __BEGIN_DECLS
  157 int     __acl_aclcheck_fd(int _filedes, acl_type_t _type, struct acl *_aclp);
  158 int     __acl_aclcheck_file(const char *_path, acl_type_t _type,
  159             struct acl *_aclp);
  160 int     __acl_aclcheck_link(const char *_path, acl_type_t _type,
  161             struct acl *_aclp);
  162 int     __acl_delete_fd(int _filedes, acl_type_t _type);
  163 int     __acl_delete_file(const char *_path_p, acl_type_t _type);
  164 int     __acl_delete_link(const char *_path_p, acl_type_t _type);
  165 int     __acl_get_fd(int _filedes, acl_type_t _type, struct acl *_aclp);
  166 int     __acl_get_file(const char *_path, acl_type_t _type, struct acl *_aclp);
  167 int     __acl_get_link(const char *_path, acl_type_t _type, struct acl *_aclp);
  168 int     __acl_set_fd(int _filedes, acl_type_t _type, struct acl *_aclp);
  169 int     __acl_set_file(const char *_path, acl_type_t _type, struct acl *_aclp);
  170 int     __acl_set_link(const char *_path, acl_type_t _type, struct acl *_aclp);
  171 __END_DECLS
  172 
  173 /*
  174  * Supported POSIX.1e ACL manipulation and assignment/retrieval API _np calls
  175  * are local extensions that reflect an environment capable of opening file
  176  * descriptors of directories, and allowing additional ACL type for different
  177  * filesystems (i.e., AFS).
  178  */
  179 __BEGIN_DECLS
  180 int     acl_add_perm(acl_permset_t _permset_d, acl_perm_t _perm);
  181 int     acl_calc_mask(acl_t *_acl_p);
  182 int     acl_clear_perms(acl_permset_t _permset_d);
  183 int     acl_copy_entry(acl_entry_t _dest_d, acl_entry_t _src_d);
  184 ssize_t acl_copy_ext(void *_buf_p, acl_t _acl, ssize_t _size);
  185 acl_t   acl_copy_int(const void *_buf_p);
  186 int     acl_create_entry(acl_t *_acl_p, acl_entry_t *_entry_p);
  187 int     acl_delete_entry(acl_t _acl, acl_entry_t _entry_d);
  188 int     acl_delete_fd_np(int _filedes, acl_type_t _type);
  189 int     acl_delete_file_np(const char *_path_p, acl_type_t _type);
  190 int     acl_delete_link_np(const char *_path_p, acl_type_t _type);
  191 int     acl_delete_def_file(const char *_path_p);
  192 int     acl_delete_def_link_np(const char *_path_p);
  193 int     acl_delete_perm(acl_permset_t _permset_d, acl_perm_t _perm);
  194 acl_t   acl_dup(acl_t _acl);
  195 int     acl_free(void *_obj_p);
  196 acl_t   acl_from_text(const char *_buf_p);
  197 int     acl_get_entry(acl_t _acl, int _entry_id, acl_entry_t *_entry_p);
  198 acl_t   acl_get_fd(int _fd);
  199 acl_t   acl_get_fd_np(int fd, acl_type_t _type);
  200 acl_t   acl_get_file(const char *_path_p, acl_type_t _type);
  201 acl_t   acl_get_link_np(const char *_path_p, acl_type_t _type);
  202 void    *acl_get_qualifier(acl_entry_t _entry_d);
  203 int     acl_get_perm_np(acl_permset_t _permset_d, acl_perm_t _perm);
  204 int     acl_get_permset(acl_entry_t _entry_d, acl_permset_t *_permset_p);
  205 int     acl_get_tag_type(acl_entry_t _entry_d, acl_tag_t *_tag_type_p);
  206 acl_t   acl_init(int _count);
  207 int     acl_set_fd(int _fd, acl_t _acl);
  208 int     acl_set_fd_np(int _fd, acl_t _acl, acl_type_t _type);
  209 int     acl_set_file(const char *_path_p, acl_type_t _type, acl_t _acl);
  210 int     acl_set_link_np(const char *_path_p, acl_type_t _type, acl_t _acl);
  211 int     acl_set_permset(acl_entry_t _entry_d, acl_permset_t _permset_d);
  212 int     acl_set_qualifier(acl_entry_t _entry_d, const void *_tag_qualifier_p);
  213 int     acl_set_tag_type(acl_entry_t _entry_d, acl_tag_t _tag_type);
  214 ssize_t acl_size(acl_t _acl);
  215 char    *acl_to_text(acl_t _acl, ssize_t *_len_p);
  216 int     acl_valid(acl_t _acl);
  217 int     acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl);
  218 int     acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl);
  219 int     acl_valid_link_np(const char *_path_p, acl_type_t _type, acl_t _acl);
  220 __END_DECLS
  221 
  222 #endif /* !_KERNEL */
  223 
  224 #endif /* !_SYS_ACL_H_ */

Cache object: 137efa5c33c9b0e02108fbaf970b1667


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.