1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | Copyright (C) Andrew Tridgell 1992-1997
|
---|
5 | Copyright (C) Luke Kenneth Casson Leighton 1996-1997
|
---|
6 | Copyright (C) Paul Ashton 1997
|
---|
7 | Copyright (C) Gerald (Jerry) Carter 2005
|
---|
8 |
|
---|
9 | This program is free software; you can redistribute it and/or modify
|
---|
10 | it under the terms of the GNU General Public License as published by
|
---|
11 | the Free Software Foundation; either version 3 of the License, or
|
---|
12 | (at your option) any later version.
|
---|
13 |
|
---|
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 |
|
---|
19 | You should have received a copy of the GNU General Public License
|
---|
20 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef _RPC_MISC_H /* _RPC_MISC_H */
|
---|
24 | #define _RPC_MISC_H
|
---|
25 |
|
---|
26 | #define SMB_RPC_INTERFACE_VERSION 1
|
---|
27 | #define PRS_POINTER_CAST bool (*)(const char*, prs_struct*, int, void*)
|
---|
28 |
|
---|
29 | enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_TERMINATE = 2, UNI_BROKEN_NON_NULL = 3, UNI_STR_DBLTERMINATE = 4 };
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | /**********************************************************************
|
---|
34 | * well-known RIDs - Relative IDs
|
---|
35 | **********************************************************************/
|
---|
36 |
|
---|
37 | /* RIDs - Well-known users ... */
|
---|
38 | #define DOMAIN_USER_RID_ADMIN (0x000001F4L)
|
---|
39 | #define DOMAIN_USER_RID_GUEST (0x000001F5L)
|
---|
40 | #define DOMAIN_USER_RID_KRBTGT (0x000001F6L)
|
---|
41 |
|
---|
42 | /* RIDs - well-known groups ... */
|
---|
43 | #define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
|
---|
44 | #define DOMAIN_GROUP_RID_USERS (0x00000201L)
|
---|
45 | #define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
|
---|
46 | #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L)
|
---|
47 |
|
---|
48 | #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L)
|
---|
49 | #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L)
|
---|
50 | #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L)
|
---|
51 | #define DOMAIN_GROUP_RID_ENTERPRISE_ADMINS (0x00000207L)
|
---|
52 |
|
---|
53 | /* is the following the right number? I bet it is --simo
|
---|
54 | #define DOMAIN_GROUP_RID_POLICY_ADMINS (0x00000208L)
|
---|
55 | */
|
---|
56 |
|
---|
57 | /* RIDs - well-known aliases ... */
|
---|
58 | #define BUILTIN_ALIAS_RID_ADMINS (0x00000220L)
|
---|
59 | #define BUILTIN_ALIAS_RID_USERS (0x00000221L)
|
---|
60 | #define BUILTIN_ALIAS_RID_GUESTS (0x00000222L)
|
---|
61 | #define BUILTIN_ALIAS_RID_POWER_USERS (0x00000223L)
|
---|
62 |
|
---|
63 | #define BUILTIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
|
---|
64 | #define BUILTIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
|
---|
65 | #define BUILTIN_ALIAS_RID_PRINT_OPS (0x00000226L)
|
---|
66 | #define BUILTIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
|
---|
67 |
|
---|
68 | #define BUILTIN_ALIAS_RID_REPLICATOR (0x00000228L)
|
---|
69 | #define BUILTIN_ALIAS_RID_RAS_SERVERS (0x00000229L)
|
---|
70 | #define BUILTIN_ALIAS_RID_PRE_2K_ACCESS (0x0000022aL)
|
---|
71 |
|
---|
72 |
|
---|
73 | /**********************************************************************
|
---|
74 | * Masks for mappings between unix uid and gid types and
|
---|
75 | * NT RIDS.
|
---|
76 | **********************************************************************/
|
---|
77 |
|
---|
78 | #define BASE_RID (0x000003E8L)
|
---|
79 |
|
---|
80 | /* Take the bottom bit. */
|
---|
81 | #define RID_TYPE_MASK 1
|
---|
82 | #define RID_MULTIPLIER 2
|
---|
83 |
|
---|
84 | /* The two common types. */
|
---|
85 | #define USER_RID_TYPE 0
|
---|
86 | #define GROUP_RID_TYPE 1
|
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 | /**********************************************************************
|
---|
91 | * RPC policy handle used pretty much everywhere
|
---|
92 | **********************************************************************/
|
---|
93 |
|
---|
94 | typedef struct policy_handle POLICY_HND;
|
---|
95 | typedef struct {
|
---|
96 | uint32 ptr_hnd; /* pointer to enumeration handle */
|
---|
97 | uint32 handle; /* enumeration handle */
|
---|
98 | } ENUM_HND;
|
---|
99 |
|
---|
100 | #define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
|
---|
101 | ( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
|
---|
102 | "OTHER")), ((unsigned int)IVAL((hnd)->uuid.node,2)),\
|
---|
103 | ((unsigned int)sys_getpid() )
|
---|
104 |
|
---|
105 |
|
---|
106 | /**********************************************************************
|
---|
107 | * Buffer Headers -- use by SEC_DESC_BUF in winreg and netlogon code
|
---|
108 | **********************************************************************/
|
---|
109 |
|
---|
110 | /* TODO: replace this with an encompassing buffer structure */
|
---|
111 | typedef struct {
|
---|
112 | uint32 buf_max_len;
|
---|
113 | uint32 buf_len;
|
---|
114 | } BUFHDR;
|
---|
115 |
|
---|
116 | /* this is a BUFHDR + a pointer to a buffer */
|
---|
117 | typedef struct {
|
---|
118 | uint32 info_level;
|
---|
119 | uint32 length; /* uint8 chars */
|
---|
120 | uint32 buffer;
|
---|
121 | } BUFHDR2;
|
---|
122 |
|
---|
123 | /* generic buffer ? wrapped around void*? */
|
---|
124 | typedef struct {
|
---|
125 | uint32 size;
|
---|
126 | uint32 buffer;
|
---|
127 | } BUFHDR4;
|
---|
128 |
|
---|
129 |
|
---|
130 | /**********************************************************************
|
---|
131 | * Buffers
|
---|
132 | **********************************************************************/
|
---|
133 |
|
---|
134 | /* buffer used by \winreg\ calls to fill in arbitrary REG_XXX values.
|
---|
135 | It *may* look like a UNISTR2 but it is *not*. This is not a goof
|
---|
136 | by the winreg developers. It is a generic buffer. buffer length
|
---|
137 | is stored in bytes (not # of uint16's) */
|
---|
138 |
|
---|
139 | typedef struct {
|
---|
140 | uint32 buf_max_len;
|
---|
141 | uint32 offset;
|
---|
142 | uint32 buf_len;
|
---|
143 | uint16 *buffer;
|
---|
144 | } REGVAL_BUFFER;
|
---|
145 |
|
---|
146 | /* generic rpc version of the DATA_BLOB. Just a length and uint8 array */
|
---|
147 |
|
---|
148 | typedef struct {
|
---|
149 | uint32 buf_len;
|
---|
150 | uint8 *buffer;
|
---|
151 | } RPC_DATA_BLOB;
|
---|
152 |
|
---|
153 | /**********************************************************************
|
---|
154 | * Buffers use by spoolss (i might be able to replace it with
|
---|
155 | * an RPC_DATA_BLOB)
|
---|
156 | **********************************************************************/
|
---|
157 |
|
---|
158 | typedef struct {
|
---|
159 | uint32 buf_len;
|
---|
160 | uint16 *buffer; /* data */
|
---|
161 | } BUFFER5;
|
---|
162 |
|
---|
163 |
|
---|
164 | /**********************************************************************
|
---|
165 | * Unicode and basic string headers
|
---|
166 | **********************************************************************/
|
---|
167 |
|
---|
168 | typedef struct {
|
---|
169 | uint16 str_str_len;
|
---|
170 | uint16 str_max_len;
|
---|
171 | uint32 buffer; /* non-zero */
|
---|
172 | } STRHDR;
|
---|
173 |
|
---|
174 | typedef struct {
|
---|
175 | uint16 uni_str_len;
|
---|
176 | uint16 uni_max_len;
|
---|
177 | uint32 buffer;
|
---|
178 | } UNIHDR;
|
---|
179 |
|
---|
180 | /**********************************************************************
|
---|
181 | * UNICODE string variations
|
---|
182 | **********************************************************************/
|
---|
183 |
|
---|
184 |
|
---|
185 | typedef struct { /* UNISTR - unicode string size and buffer */
|
---|
186 | uint16 *buffer; /* unicode characters. ***MUST*** be
|
---|
187 | little-endian. ***MUST*** be null-terminated */
|
---|
188 | } UNISTR;
|
---|
189 |
|
---|
190 | typedef struct { /* UNISTR2 - unicode string size (in
|
---|
191 | uint16 unicode chars) and buffer */
|
---|
192 | uint32 uni_max_len;
|
---|
193 | uint32 offset;
|
---|
194 | uint32 uni_str_len;
|
---|
195 | uint16 *buffer; /* unicode characters. ***MUST*** be little-endian.
|
---|
196 | **must** be null-terminated and the uni_str_len
|
---|
197 | should include the NULL character */
|
---|
198 | } UNISTR2;
|
---|
199 |
|
---|
200 | /* i think this is the same as a BUFFER5 used in the spoolss code --jerry */
|
---|
201 | /* not sure about how the termination matches between the uint16 buffers thought */
|
---|
202 |
|
---|
203 | typedef struct { /* UNISTR3 - XXXX not sure about this structure */
|
---|
204 | uint32 uni_str_len;
|
---|
205 | UNISTR str;
|
---|
206 | } UNISTR3;
|
---|
207 |
|
---|
208 | typedef struct { /* Buffer wrapped around a UNISTR2 */
|
---|
209 | uint16 length; /* number of bytes not counting NULL terminatation */
|
---|
210 | uint16 size; /* number of bytes including NULL terminatation */
|
---|
211 | UNISTR2 *string;
|
---|
212 | } UNISTR4;
|
---|
213 |
|
---|
214 | typedef struct {
|
---|
215 | uint32 count;
|
---|
216 | UNISTR4 *strings;
|
---|
217 | } UNISTR4_ARRAY;
|
---|
218 |
|
---|
219 |
|
---|
220 | /**********************************************************************
|
---|
221 | * String variations
|
---|
222 | **********************************************************************/
|
---|
223 |
|
---|
224 | typedef struct { /* STRING2 - string size (in uint8 chars) and buffer */
|
---|
225 | uint32 str_max_len;
|
---|
226 | uint32 offset;
|
---|
227 | uint32 str_str_len;
|
---|
228 | uint8 *buffer; /* uint8 characters. **NOT** necessarily null-terminated */
|
---|
229 | } STRING2;
|
---|
230 |
|
---|
231 |
|
---|
232 |
|
---|
233 |
|
---|
234 | /**********************************************************************
|
---|
235 | * Domain SID structures
|
---|
236 | **********************************************************************/
|
---|
237 |
|
---|
238 | typedef struct {
|
---|
239 | uint32 num_auths; /* length, bytes, including length of len :-) */
|
---|
240 | DOM_SID sid;
|
---|
241 | } DOM_SID2;
|
---|
242 |
|
---|
243 |
|
---|
244 | /**********************************************************************
|
---|
245 | * Domain SID structures
|
---|
246 | **********************************************************************/
|
---|
247 |
|
---|
248 | /* DOM_RID - domain RID structure for ntlsa pipe */
|
---|
249 | typedef struct {
|
---|
250 | uint16 type; /* value is SID_NAME_USE enum */
|
---|
251 | uint32 rid;
|
---|
252 | uint32 rid_idx; /* referenced domain index */
|
---|
253 | } DOM_RID;
|
---|
254 |
|
---|
255 | /* DOM_RID2 - second domain RID structure for ntlsa pipe */
|
---|
256 | typedef struct {
|
---|
257 | uint16 type; /* value is SID_NAME_USE enum */
|
---|
258 | uint32 rid;
|
---|
259 | uint32 rid_idx; /* referenced domain index */
|
---|
260 | uint32 unknown;
|
---|
261 | } DOM_RID2;
|
---|
262 |
|
---|
263 | typedef struct { /* DOM_RID3 - domain RID structure for samr pipe */
|
---|
264 | uint32 rid; /* domain-relative (to a SID) id */
|
---|
265 | uint32 type1; /* value is 0x1 */
|
---|
266 | uint32 ptr_type; /* undocumented pointer */
|
---|
267 | uint32 type2; /* value is 0x1 */
|
---|
268 | uint32 unk; /* value is 0x2 */
|
---|
269 | } DOM_RID3;
|
---|
270 |
|
---|
271 | /* DOM_RID4 - rid + user attributes */
|
---|
272 | typedef struct domrid4_info
|
---|
273 | {
|
---|
274 | uint32 unknown;
|
---|
275 | uint16 attr;
|
---|
276 | uint32 rid; /* user RID */
|
---|
277 | } DOM_RID4;
|
---|
278 |
|
---|
279 | /* DOM_GID - group id + user attributes */
|
---|
280 | typedef struct {
|
---|
281 | uint32 g_rid; /* a group RID */
|
---|
282 | uint32 attr;
|
---|
283 | } DOM_GID;
|
---|
284 |
|
---|
285 | /**********************************************************************
|
---|
286 | * ????
|
---|
287 | **********************************************************************/
|
---|
288 |
|
---|
289 | /* DOM_CLNT_SRV - client / server names */
|
---|
290 | typedef struct clnt_srv_info {
|
---|
291 | uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
|
---|
292 | UNISTR2 uni_logon_srv; /* logon server name */
|
---|
293 | uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
|
---|
294 | UNISTR2 uni_comp_name; /* client machine name */
|
---|
295 | } DOM_CLNT_SRV;
|
---|
296 |
|
---|
297 | /* DOM_LOG_INFO - login info */
|
---|
298 | typedef struct log_info {
|
---|
299 | uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
|
---|
300 | UNISTR2 uni_logon_srv; /* logon server name */
|
---|
301 | UNISTR2 uni_acct_name; /* account name */
|
---|
302 | uint16 sec_chan; /* secure channel type */
|
---|
303 | UNISTR2 uni_comp_name; /* client machine name */
|
---|
304 | } DOM_LOG_INFO;
|
---|
305 |
|
---|
306 | /* DOM_CHAL - challenge info */
|
---|
307 | typedef struct chal_info {
|
---|
308 | unsigned char data[8]; /* credentials */
|
---|
309 | } DOM_CHAL;
|
---|
310 |
|
---|
311 | /* DOM_CREDs - timestamped client or server credentials */
|
---|
312 | typedef struct cred_info {
|
---|
313 | DOM_CHAL challenge; /* credentials */
|
---|
314 | UTIME timestamp; /* credential time-stamp */
|
---|
315 | } DOM_CRED;
|
---|
316 |
|
---|
317 | /* DOM_CLNT_INFO - client info */
|
---|
318 | typedef struct clnt_info {
|
---|
319 | DOM_LOG_INFO login;
|
---|
320 | DOM_CRED cred;
|
---|
321 | } DOM_CLNT_INFO;
|
---|
322 |
|
---|
323 | /* DOM_CLNT_INFO2 - client info */
|
---|
324 | typedef struct clnt_info2 {
|
---|
325 | DOM_CLNT_SRV login;
|
---|
326 | uint32 ptr_cred;
|
---|
327 | DOM_CRED cred;
|
---|
328 | } DOM_CLNT_INFO2;
|
---|
329 |
|
---|
330 | /* DOM_LOGON_ID - logon id */
|
---|
331 | typedef struct logon_info {
|
---|
332 | uint32 low;
|
---|
333 | uint32 high;
|
---|
334 | } DOM_LOGON_ID;
|
---|
335 |
|
---|
336 | /* OWF INFO */
|
---|
337 | typedef struct owf_info {
|
---|
338 | uint8 data[16];
|
---|
339 | } OWF_INFO;
|
---|
340 |
|
---|
341 |
|
---|
342 | #endif /* _RPC_MISC_H */
|
---|