Print this page
    
remove support for non-ANSI compilation
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/acl.h
          +++ new/usr/src/uts/common/sys/acl.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  
    | ↓ open down ↓ | 11 lines elided | ↑ open up ↑ | 
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
       23 + *
  22   24   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   25   * Use is subject to license terms.
  24   26   */
  25   27  
  26   28  #ifndef _SYS_ACL_H
  27   29  #define _SYS_ACL_H
  28   30  
  29   31  #include <sys/types.h>
  30   32  #include <sys/acl_impl.h>
  31   33  
  32   34  #ifdef  __cplusplus
  33   35  extern "C" {
  34   36  #endif
  35   37  
  36   38  #define MAX_ACL_ENTRIES         (1024)  /* max entries of each type */
  37   39  typedef struct acl {
  38   40          int             a_type;         /* the type of ACL entry */
  39   41          uid_t           a_id;           /* the entry in -uid or gid */
  40   42          o_mode_t        a_perm;         /* the permission field */
  41   43  } aclent_t;
  42   44  
  43   45  typedef struct ace {
  44   46          uid_t           a_who;          /* uid or gid */
  45   47          uint32_t        a_access_mask;  /* read,write,... */
  46   48          uint16_t        a_flags;        /* see below */
  47   49          uint16_t        a_type;         /* allow or deny */
  48   50  } ace_t;
  49   51  
  50   52  typedef struct acl_info acl_t;
  51   53  
  52   54  /*
  53   55   * The following are Defined types for an aclent_t.
  54   56   */
  55   57  #define USER_OBJ        (0x01)          /* object owner */
  56   58  #define USER            (0x02)          /* additional users */
  57   59  #define GROUP_OBJ       (0x04)          /* owning group of the object */
  58   60  #define GROUP           (0x08)          /* additional groups */
  59   61  #define CLASS_OBJ       (0x10)          /* file group class and mask entry */
  60   62  #define OTHER_OBJ       (0x20)          /* other entry for the object */
  61   63  #define ACL_DEFAULT     (0x1000)        /* default flag */
  62   64  /* default object owner */
  63   65  #define DEF_USER_OBJ    (ACL_DEFAULT | USER_OBJ)
  64   66  /* default additional users */
  65   67  #define DEF_USER        (ACL_DEFAULT | USER)
  66   68  /* default owning group */
  67   69  #define DEF_GROUP_OBJ   (ACL_DEFAULT | GROUP_OBJ)
  68   70  /* default additional groups */
  69   71  #define DEF_GROUP       (ACL_DEFAULT | GROUP)
  70   72  /* default mask entry */
  71   73  #define DEF_CLASS_OBJ   (ACL_DEFAULT | CLASS_OBJ)
  72   74  /* default other entry */
  73   75  #define DEF_OTHER_OBJ   (ACL_DEFAULT | OTHER_OBJ)
  74   76  
  75   77  /*
  76   78   * The following are defined for ace_t.
  77   79   */
  78   80  #define ACE_READ_DATA           0x00000001
  79   81  #define ACE_LIST_DIRECTORY      0x00000001
  80   82  #define ACE_WRITE_DATA          0x00000002
  81   83  #define ACE_ADD_FILE            0x00000002
  82   84  #define ACE_APPEND_DATA         0x00000004
  83   85  #define ACE_ADD_SUBDIRECTORY    0x00000004
  84   86  #define ACE_READ_NAMED_ATTRS    0x00000008
  85   87  #define ACE_WRITE_NAMED_ATTRS   0x00000010
  86   88  #define ACE_EXECUTE             0x00000020
  87   89  #define ACE_DELETE_CHILD        0x00000040
  88   90  #define ACE_READ_ATTRIBUTES     0x00000080
  89   91  #define ACE_WRITE_ATTRIBUTES    0x00000100
  90   92  #define ACE_DELETE              0x00010000
  91   93  #define ACE_READ_ACL            0x00020000
  92   94  #define ACE_WRITE_ACL           0x00040000
  93   95  #define ACE_WRITE_OWNER         0x00080000
  94   96  #define ACE_SYNCHRONIZE         0x00100000
  95   97  
  96   98  #define ACE_FILE_INHERIT_ACE            0x0001
  97   99  #define ACE_DIRECTORY_INHERIT_ACE       0x0002
  98  100  #define ACE_NO_PROPAGATE_INHERIT_ACE    0x0004
  99  101  #define ACE_INHERIT_ONLY_ACE            0x0008
 100  102  #define ACE_SUCCESSFUL_ACCESS_ACE_FLAG  0x0010
 101  103  #define ACE_FAILED_ACCESS_ACE_FLAG      0x0020
 102  104  #define ACE_IDENTIFIER_GROUP            0x0040
 103  105  #define ACE_INHERITED_ACE               0x0080
 104  106  #define ACE_OWNER                       0x1000
 105  107  #define ACE_GROUP                       0x2000
 106  108  #define ACE_EVERYONE                    0x4000
 107  109  
 108  110  #define ACE_ACCESS_ALLOWED_ACE_TYPE     0x0000
 109  111  #define ACE_ACCESS_DENIED_ACE_TYPE      0x0001
 110  112  #define ACE_SYSTEM_AUDIT_ACE_TYPE       0x0002
 111  113  #define ACE_SYSTEM_ALARM_ACE_TYPE       0x0003
 112  114  
 113  115  #define ACL_AUTO_INHERIT                0x0001
 114  116  #define ACL_PROTECTED                   0x0002
 115  117  #define ACL_DEFAULTED                   0x0004
 116  118  #define ACL_FLAGS_ALL                   (ACL_AUTO_INHERIT|ACL_PROTECTED| \
 117  119      ACL_DEFAULTED)
 118  120  
 119  121  #ifdef _KERNEL
 120  122  
 121  123  /*
 122  124   * These are only applicable in a CIFS context.
 123  125   */
 124  126  #define ACE_ACCESS_ALLOWED_COMPOUND_ACE_TYPE            0x04
 125  127  #define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE              0x05
 126  128  #define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE               0x06
 127  129  #define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE                0x07
 128  130  #define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE                0x08
 129  131  #define ACE_ACCESS_ALLOWED_CALLBACK_ACE_TYPE            0x09
 130  132  #define ACE_ACCESS_DENIED_CALLBACK_ACE_TYPE             0x0A
 131  133  #define ACE_ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE     0x0B
 132  134  #define ACE_ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE      0x0C
 133  135  #define ACE_SYSTEM_AUDIT_CALLBACK_ACE_TYPE              0x0D
 134  136  #define ACE_SYSTEM_ALARM_CALLBACK_ACE_TYPE              0x0E
 135  137  #define ACE_SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE       0x0F
 136  138  #define ACE_SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE       0x10
 137  139  
 138  140  #define ACE_ALL_TYPES   0x001F
 139  141  
 140  142  typedef struct ace_object {
 141  143          uid_t           a_who;          /* uid or gid */
 142  144          uint32_t        a_access_mask;  /* read,write,... */
 143  145          uint16_t        a_flags;        /* see below */
 144  146          uint16_t        a_type;         /* allow or deny */
 145  147          uint8_t         a_obj_type[16]; /* obj type */
 146  148          uint8_t         a_inherit_obj_type[16];  /* inherit obj */
 147  149  } ace_object_t;
 148  150  
 149  151  #endif
 150  152  
 151  153  #define ACE_ALL_PERMS   (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
 152  154      ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
 153  155      ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
 154  156      ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
 155  157      ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
 156  158  
 157  159  #define ACE_ALL_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA| \
 158  160      ACE_WRITE_ATTRIBUTES|ACE_WRITE_NAMED_ATTRS|ACE_WRITE_ACL| \
 159  161      ACE_WRITE_OWNER|ACE_DELETE|ACE_DELETE_CHILD)
 160  162  
 161  163  #define ACE_READ_PERMS  (ACE_READ_DATA|ACE_READ_ACL|ACE_READ_ATTRIBUTES| \
 162  164      ACE_READ_NAMED_ATTRS)
 163  165  
 164  166  #define ACE_WRITE_PERMS (ACE_WRITE_DATA|ACE_APPEND_DATA|ACE_WRITE_ATTRIBUTES| \
 165  167      ACE_WRITE_NAMED_ATTRS)
 166  168  
 167  169  #define ACE_MODIFY_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
 168  170      ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
 169  171      ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
 170  172      ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_SYNCHRONIZE)
 171  173  /*
 172  174   * The following flags are supported by both NFSv4 ACLs and ace_t.
 173  175   */
 174  176  #define ACE_NFSV4_SUP_FLAGS (ACE_FILE_INHERIT_ACE | \
 175  177      ACE_DIRECTORY_INHERIT_ACE | \
 176  178      ACE_NO_PROPAGATE_INHERIT_ACE | \
 177  179      ACE_INHERIT_ONLY_ACE | \
 178  180      ACE_IDENTIFIER_GROUP)
 179  181  
 180  182  #define ACE_TYPE_FLAGS          (ACE_OWNER|ACE_GROUP|ACE_EVERYONE| \
 181  183      ACE_IDENTIFIER_GROUP)
 182  184  #define ACE_INHERIT_FLAGS       (ACE_FILE_INHERIT_ACE| \
 183  185      ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|ACE_INHERIT_ONLY_ACE)
 184  186  
 185  187  /* cmd args to acl(2) for aclent_t  */
 186  188  #define GETACL                  1
 187  189  #define SETACL                  2
 188  190  #define GETACLCNT               3
 189  191  
 190  192  /* cmd's to manipulate ace acls. */
 191  193  #define ACE_GETACL              4
 192  194  #define ACE_SETACL              5
 193  195  #define ACE_GETACLCNT           6
 194  196  
 195  197  /* minimal acl entries from GETACLCNT */
 196  198  #define MIN_ACL_ENTRIES         4
 197  199  
 198  200  #if !defined(_KERNEL)
 199  201  
 200  202  /* acl check errors */
 201  203  #define GRP_ERROR               1
 202  204  #define USER_ERROR              2
 203  205  #define OTHER_ERROR             3
 204  206  #define CLASS_ERROR             4
 205  207  #define DUPLICATE_ERROR         5
 206  208  #define MISS_ERROR              6
 207  209  #define MEM_ERROR               7
 208  210  #define ENTRY_ERROR             8
 209  211  
 210  212  
 211  213  /*
 212  214   * similar to ufs_acl.h: changed to char type for user commands (tar, cpio)
 213  215   * Attribute types
 214  216   */
 215  217  #define UFSD_FREE       ('0')   /* Free entry */
 216  218  #define UFSD_ACL        ('1')   /* Access Control Lists */
 217  219  #define UFSD_DFACL      ('2')   /* reserved for future use */
 218  220  #define ACE_ACL         ('3')   /* ace_t style acls */
 219  221  
 220  222  /*
 221  223   * flag to [f]acl_get()
 222  224   * controls whether a trivial acl should be returned.
 223  225   */
 224  226  #define ACL_NO_TRIVIAL  0x2
 225  227  
 226  228  
 227  229  /*
 228  230   * Flags to control acl_totext()
 229  231   */
 230  232  
 231  233  #define ACL_APPEND_ID   0x1     /* append uid/gid to user/group entries */
 232  234  #define ACL_COMPACT_FMT 0x2     /* build ACL in ls -V format */
 233  235  #define ACL_NORESOLVE   0x4     /* don't do name service lookups */
 234  236  #define ACL_SID_FMT     0x8     /* use usersid/groupsid when appropriate */
 235  237  
 236  238  /*
 237  239   * Legacy aclcheck errors for aclent_t ACLs
 238  240   */
 239  241  #define EACL_GRP_ERROR          GRP_ERROR
 240  242  #define EACL_USER_ERROR         USER_ERROR
 241  243  #define EACL_OTHER_ERROR        OTHER_ERROR
 242  244  #define EACL_CLASS_ERROR        CLASS_ERROR
 243  245  #define EACL_DUPLICATE_ERROR    DUPLICATE_ERROR
 244  246  #define EACL_MISS_ERROR         MISS_ERROR
 245  247  #define EACL_MEM_ERROR          MEM_ERROR
 246  248  #define EACL_ENTRY_ERROR        ENTRY_ERROR
 247  249  
 248  250  #define EACL_INHERIT_ERROR      9               /* invalid inherit flags */
 249  251  #define EACL_FLAGS_ERROR        10              /* unknown flag value */
 250  252  #define EACL_PERM_MASK_ERROR    11              /* unknown permission */
 251  253  #define EACL_COUNT_ERROR        12              /* invalid acl count */
 252  254  
 253  255  #define EACL_INVALID_SLOT       13              /* invalid acl slot */
 254  256  #define EACL_NO_ACL_ENTRY       14              /* Entry doesn't exist */
 255  257  #define EACL_DIFF_TYPE          15              /* acls aren't same type */
 256  258  
 257  259  #define EACL_INVALID_USER_GROUP 16              /* need user/group name */
 258  260  #define EACL_INVALID_STR        17              /* invalid acl string */
 259  261  #define EACL_FIELD_NOT_BLANK    18              /* can't have blank field */
 260  262  #define EACL_INVALID_ACCESS_TYPE 19             /* invalid access type */
 261  263  #define EACL_UNKNOWN_DATA       20              /* Unrecognized data in ACL */
 262  264  #define EACL_MISSING_FIELDS     21              /* missing fields in acl */
 263  265  
 264  266  #define EACL_INHERIT_NOTDIR     22              /* Need dir for inheritance */
 265  267  
 266  268  extern int aclcheck(aclent_t *, int, int *);
 267  269  extern int acltomode(aclent_t *, int, mode_t *);
 268  270  extern int aclfrommode(aclent_t *, int, mode_t *);
 269  271  extern int aclsort(int, int, aclent_t *);
 270  272  extern char *acltotext(aclent_t *, int);
 271  273  extern aclent_t *aclfromtext(char *, int *);
 272  274  extern void acl_free(acl_t *);
 273  275  extern int acl_get(const char *, int, acl_t **);
 274  276  extern int facl_get(int, int, acl_t **);
 275  277  extern int acl_set(const char *, acl_t *acl);
 276  278  extern int facl_set(int, acl_t *acl);
 277  279  extern int acl_strip(const char *, uid_t, gid_t, mode_t);
 278  280  extern int acl_trivial(const char *);
 279  281  extern char *acl_totext(acl_t *, int);
  
    | ↓ open down ↓ | 248 lines elided | ↑ open up ↑ | 
 280  282  extern int acl_fromtext(const char *, acl_t **);
 281  283  extern int acl_check(acl_t *, int);
 282  284  
 283  285  #else   /* !defined(_KERNEL) */
 284  286  
 285  287  extern void ksort(caddr_t, int, int, int (*)(void *, void *));
 286  288  extern int cmp2acls(void *, void *);
 287  289  
 288  290  #endif  /* !defined(_KERNEL) */
 289  291  
 290      -#if defined(__STDC__)
 291  292  extern int acl(const char *path, int cmd, int cnt, void *buf);
 292  293  extern int facl(int fd, int cmd, int cnt, void *buf);
 293      -#else   /* !__STDC__ */
 294      -extern int acl();
 295      -extern int facl();
 296      -#endif  /* defined(__STDC__) */
 297  294  
 298  295  #ifdef  __cplusplus
 299  296  }
 300  297  #endif
 301  298  
 302  299  #endif /* _SYS_ACL_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX