cifs-utils: struct cifs_sid definition to new cifsidmap.h header
[jlayton/cifs-utils.git] / cifsacl.h
1 /*
2 * Header file for getcifsacl and setcifsacl utilities
3 *
4 * Copyright (C) Shirish Pargaonkar (shirishp@us.ibm.com) 2011
5 *
6 * Has various access rights, security descriptor fields defines
7 * and data structures related to security descriptor, DACL, ACE,
8 * and SID.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include "cifsidmap.h"
24
25 #ifndef _CIFSACL_H
26 #define _CIFSACL_H
27
28 #define BUFSIZE 1024
29 #define ATTRNAME "system.cifs_acl"
30
31 #define MAX_NUM_AUTHS 6
32
33 /* File specific rights */
34 #define READ_DATA       0x00000001 /* R */
35 #define WRITE_DATA      0x00000002 /* W */
36 #define APPEND_DATA     0x00000004 /* A */
37 #define READ_EA         0x00000008 /* REA */
38 #define WRITE_EA        0x00000010 /* WEA */
39 #define EXEC            0x00000020 /* E */
40 #define DELDHLD         0x00000040 /* DC */
41 #define READ_ATTR       0x00000080 /* RA */
42 #define WRITE_ATTR      0x00000100 /* WA */
43
44 /* Standard rights */
45 #define DELETE          0x00010000 /* D */
46 #define READ_CONTROL    0x00020000 /* RC */
47 #define WRITE_DAC       0x00040000 /* P */
48 #define WRITE_OWNER     0x00080000 /* O */
49 #define SYNC            0x00100000 /* S */
50
51 /* Generic rights */
52 #define SYSSEC          0x01000000
53 #define MAX             0x02000000
54 #define ALL             0x10000000
55 #define EXECUTE         0x20000000 /* GE */
56 #define WRITE           0x40000000 /* GW */
57 #define READ            0x80000000 /* GR */
58
59 /* D | RC | P | O | S | R | W | A | E | DC | REA | WEA | RA | WA  */
60 #define FULL_CONTROL    0x001f01ff
61
62 /* RC | S | R | E | REA | RA */
63 #define EREAD           0x001200a9
64
65 /* RC | S | R | E | REA | GR | GE */
66 #define OREAD           0xa01200a1
67
68 /* RC | S | R | REA | RA */
69 #define BREAD           0x00120089
70
71 /* W | A | WA | WEA| */
72 #define EWRITE          0x00000116
73
74 /* D | RC | S | R | W | A | E |REA | WEA | RA | WA */
75 #define CHANGE          0x001301bf
76
77 /* GR | RC | REA | RA | REA | R */
78 #define ALL_READ_BITS   0x80020089
79
80 /* WA | WEA | A | W */
81 #define ALL_WRITE_BITS  0x40000116
82
83 #define OBJECT_INHERIT_FLAG 0x01        /* OI */
84 #define CONTAINER_INHERIT_FLAG 0x02     /* CI */
85 #define NO_PROPAGATE_INHERIT_FLAG 0x04  /* NP */
86 #define INHERIT_ONLY_FLAG 0x08          /* IO */
87 #define INHERITED_ACE_FLAG 0x10         /* I */
88 #define VFLAGS (OBJECT_INHERIT_FLAG|CONTAINER_INHERIT_FLAG|NO_PROPAGATE_INHERIT_FLAG|INHERIT_ONLY_FLAG|INHERITED_ACE_FLAG)
89
90 #define ACCESS_ALLOWED  0               /* ALLOWED */
91 #define ACCESS_DENIED   1               /* DENIED */
92 #define ACCESS_ALLOWED_OBJECT   5       /* OBJECT_ALLOWED */
93 #define ACCESS_DENIED_OBJECT    6       /* OBJECT_DENIED */
94
95 #define COMPSID 0x1
96 #define COMPTYPE 0x2
97 #define COMPFLAG 0x4
98 #define COMPMASK 0x8
99 #define COMPALL (COMPSID|COMPTYPE|COMPFLAG|COMPMASK)
100
101 /*
102  * While not indicated here, the structs below represent on-the-wire data
103  * structures. Any multi-byte values are expected to be little-endian!
104  *
105  * FIXME: should we change these to use endianness annotations?
106  */
107 struct cifs_ntsd {
108         uint16_t revision; /* revision level */
109         uint16_t type;
110         uint32_t osidoffset;
111         uint32_t gsidoffset;
112         uint32_t sacloffset;
113         uint32_t dacloffset;
114 } __attribute__((packed));
115
116 struct cifs_ctrl_acl {
117         uint16_t revision; /* revision level */
118         uint16_t size;
119         uint32_t num_aces;
120 } __attribute__((packed));
121
122 struct cifs_ace {
123         uint8_t type;
124         uint8_t flags;
125         uint16_t size;
126         uint32_t access_req;
127         struct cifs_sid sid; /* ie UUID of user or group who gets these perms */
128 } __attribute__((packed));
129
130 #endif /* CIFSACL_H */