summaryrefslogtreecommitdiff
path: root/librpc/idl/xattr.idl
blob: f7e698429ba647cc4c5cb5bd2bd6966b05ffee10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include "idl_types.h"

/*
   IDL structures for xattr file attributes

   this has nothing to do with RPC, we are just using our NDR/IDL
   infrastructure as a convenient way to store linearised information
   about a file in a architecture independent manner
*/

import "security.idl";

[
  uuid("12345778-1234-abcd-0001-00000002"),
  version(0.0),
  helper("../librpc/ndr/ndr_xattr.h"),
  pyhelper("librpc/ndr/py_xattr.c"),
  pointer_default(unique)
]
interface xattr
{
	const char *XATTR_DOSATTRIB_NAME = "user.DosAttrib";
	const int XATTR_DOSATTRIB_ESTIMATED_SIZE = 64;

	/* we store basic dos attributes in a DosAttrib xattr. By
	   using a union we can cope with new version of this
	   structure more easily */

	/*
	 * the FFFF level is never really used,
	 * it's used to pass the information from
	 * the old hex string attrib information
	 * we have a handwritten parser which converts
	 * the hex string to the xattr_DosInfoFFFFCompat strucure
	 */

	typedef struct {
		uint32 attrib;
	} xattr_DosInfoFFFFCompat;

	typedef struct {
		uint32 attrib;
		uint32 ea_size;
		udlong size;
		udlong alloc_size;
		NTTIME create_time;
		NTTIME change_time;
	} xattr_DosInfo1;

/*
	We use xattrDosInfo1 again when we store values.
	Because the sticky write time is now stored in the opendb
	and xattr_DosInfo2Old is only present to parse existing
	values from disk.

	const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
*/
	typedef struct {
		uint32     flags;
		uint32     attrib;
		uint32     ea_size;
		udlong     size;
		udlong     alloc_size;
		NTTIME     create_time;
		NTTIME     change_time;
		NTTIME     write_time; /* only used when sticky write time is set */
		utf8string name;
	} xattr_DosInfo2Old;

	typedef [bitmap32bit] bitmap {
		XATTR_DOSINFO_ATTRIB            = 0x00000001,
		XATTR_DOSINFO_EA_SIZE           = 0x00000002,
		XATTR_DOSINFO_SIZE              = 0x00000004,
		XATTR_DOSINFO_ALLOC_SIZE        = 0x00000008,
		XATTR_DOSINFO_CREATE_TIME       = 0x00000010,
		XATTR_DOSINFO_CHANGE_TIME       = 0x00000020
	} xattr_DosInfoValidFlags;

	typedef struct {
		xattr_DosInfoValidFlags valid_flags;
		uint32 attrib;
		uint32 ea_size;
		udlong size;
		udlong alloc_size;
		NTTIME create_time;
		NTTIME change_time;
	} xattr_DosInfo3;

	typedef [public,switch_type(uint16)] union {
		[case(0xFFFF)] xattr_DosInfoFFFFCompat compatinfoFFFF;
                [case(1)] xattr_DosInfo1 info1;
                [case(2)] xattr_DosInfo2Old oldinfo2;
		[case(3)] xattr_DosInfo3 info3;
        } xattr_DosInfo;

	typedef [public] struct {
		uint16 version;
		[switch_is(version)] xattr_DosInfo info;
	} xattr_DosAttrib;

	typedef [public,nopush,nopull,noprint] struct {
		astring attrib_hex;
		uint16 version;
		[switch_is(version)] xattr_DosInfo info;
	} xattr_DOSATTRIB;

	void xattr_parse_DOSATTRIB(
		[in] xattr_DOSATTRIB x
	);

	/* we store DOS style extended attributes in a DosEAs xattr */
	const char *XATTR_DOSEAS_NAME = "user.DosEAs";

	typedef struct {
		utf8string name;
		DATA_BLOB value;
	} xattr_EA;

	typedef [public] struct {
		uint16 num_eas;
		[size_is(num_eas)] xattr_EA *eas;
	} xattr_DosEAs;

	/* Slightly different version, used by the vfs_xattr_tdb module */
	typedef [public] struct {
		uint32 num_eas;
		xattr_EA eas[num_eas];
	} tdb_xattrs;

	/* we store stream information in this xattr structure. Then
	   the streams themselves are stored in
	   user.DosStream.STREAMNAME or in external files, according
	   to the flags */
	const char *XATTR_DOSSTREAMS_NAME = "user.DosStreams";

	const int XATTR_STREAM_FLAG_INTERNAL = 0x00000001;

	/* stream data is stored in attributes with the given prefix */
	const char *XATTR_DOSSTREAM_PREFIX = "user.DosStream.";

	const int XATTR_MAX_STREAM_SIZE     = 0x4000;
	const int XATTR_MAX_STREAM_SIZE_TDB = 0x100000;

	typedef struct {
		uint32     flags;
		udlong     size;
		udlong     alloc_size;
		utf8string name;
	} xattr_DosStream;

	typedef [public] struct {
		uint32 num_streams;
		[size_is(num_streams)] xattr_DosStream *streams;
	} xattr_DosStreams;


	/* we store the NT ACL a NTACL xattr. It is versioned so we
	   can later add other acl attribs (such as posix acl mapping)

	   we put this xattr in the security namespace to ensure that
	   only trusted users can write to the ACL

	   stored in "security.NTACL"

	   Version 1. raw SD stored as Samba4 does it.
	   Version 2. raw SD + last changed hash so we
		      can discard if this doesn't match the underlying ACL hash.
	*/

	const char *XATTR_NTACL_NAME = "security.NTACL";

	const int XATTR_SD_HASH_SIZE = 64;
	const int XATTR_SD_HASH_TYPE_NONE = 0x0;
	const int XATTR_SD_HASH_TYPE_SHA256 = 0x1;

	typedef [public] struct {
		security_descriptor *sd;
		uint8 hash[16];
	} security_descriptor_hash_v2; /* Hash never used in this version. */

	typedef [public] struct {
		security_descriptor *sd;
		uint16 hash_type;
		uint8 hash[64]; /* 64 bytes hash. */
	} security_descriptor_hash_v3;

	typedef [public] struct {
		security_descriptor *sd;
		uint16 hash_type;
		uint8 hash[64]; /* 64 bytes hash. */
		utf8string description; /* description of what created
					 * this hash (to allow
					 * foresnics later, if we have
					 * a bug in one codepath */
		NTTIME time;
		uint8 sys_acl_hash[64]; /* 64 bytes hash. */
	} security_descriptor_hash_v4;

	typedef [switch_type(uint16)] union {
		[case(1)] security_descriptor *sd;
		[case(2)] security_descriptor_hash_v2 *sd_hs2;
		[case(3)] security_descriptor_hash_v3 *sd_hs3;
		[case(4)] security_descriptor_hash_v4 *sd_hs4;
	} xattr_NTACL_Info;

	typedef [public] struct {
		uint16 version;
		[switch_is(version)] xattr_NTACL_Info info;
	} xattr_NTACL;
}