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