summaryrefslogtreecommitdiff
path: root/source4/rpc_server/winreg/rpc_winreg.c
blob: c1d6d6ad69206294007b73258a1108de482b18ee (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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
/* 
   Unix SMB/CIFS implementation.

   endpoint server for the winreg pipe

   Copyright (C) Jelmer Vernooij 2004
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "includes.h"

enum handle_types { HTYPE_REGKEY, HTYPE_REGVAL };

struct _privatedata {
	REG_HANDLE *registry;
};


/* this function is called when the client disconnects the endpoint */
static void winreg_unbind(struct dcesrv_connection *dc, const struct dcesrv_interface *di) 
{
	struct _privatedata *data = dc->private;
	if (data) reg_free(data->registry);
}

static NTSTATUS winreg_bind(struct dcesrv_call_state *dc, const struct dcesrv_interface *di) 
{
	struct _privatedata *data;
	data = talloc(dc->mem_ctx, sizeof(struct _privatedata));
	data->registry = reg_open(lp_parm_string(-1,"winreg","subsystem"),lp_parm_string(-1,"winreg", "file"), False);
	if(!data->registry) return NT_STATUS_UNSUCCESSFUL;
	dc->conn->private = data;
	return NT_STATUS_OK;
}

#define DCESRV_INTERFACE_WINREG_BIND winreg_bind
#define DCESRV_INTERFACE_WINREG_UNBIND winreg_unbind

/* 
  winreg_OpenHKCR 
*/
static NTSTATUS winreg_OpenHKCR(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKCR *r)
{
	
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKCU 
*/
static NTSTATUS winreg_OpenHKCU(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKCU *r)
{
	struct _privatedata *data = dce_call->conn->private;
	REG_KEY *root = reg_get_root(data->registry);
	REG_KEY *k = reg_open_key(root, "\\HKEY_CURRENT_USER");

	if(!k) {
		r->out.result = WERR_BADFILE;
	} else {
		struct dcesrv_handle *h = dcesrv_handle_new(dce_call->conn, HTYPE_REGKEY);
		h->data = k;
		r->out.handle = &h->wire_handle;
	}

	r->out.result = WERR_OK;

	return NT_STATUS_OK;
}


/* 
  winreg_OpenHKLM 
*/
static NTSTATUS winreg_OpenHKLM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKLM *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKPD 
*/
static NTSTATUS winreg_OpenHKPD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKPD *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKU 
*/
static NTSTATUS winreg_OpenHKU(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKU *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_CloseKey 
*/
static NTSTATUS winreg_CloseKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_CloseKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_CreateKey 
*/
static NTSTATUS winreg_CreateKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_CreateKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_DeleteKey 
*/
static NTSTATUS winreg_DeleteKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_DeleteKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_DeleteValue 
*/
static NTSTATUS winreg_DeleteValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_DeleteValue *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_EnumKey 
*/
static NTSTATUS winreg_EnumKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_EnumKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_EnumValue 
*/
static NTSTATUS winreg_EnumValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_EnumValue *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_FlushKey 
*/
static NTSTATUS winreg_FlushKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_FlushKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_GetKeySecurity 
*/
static NTSTATUS winreg_GetKeySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_GetKeySecurity *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_LoadKey 
*/
static NTSTATUS winreg_LoadKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_LoadKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_NotifyChangeKeyValue 
*/
static NTSTATUS winreg_NotifyChangeKeyValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_NotifyChangeKeyValue *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenKey 
*/
static NTSTATUS winreg_OpenKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenKey *r)
{
	struct dcesrv_handle *h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
	if(!h) {
		return NT_STATUS_INVALID_HANDLE;
	}
	
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_QueryInfoKey 
*/
static NTSTATUS winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_QueryInfoKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_QueryValue 
*/
static NTSTATUS winreg_QueryValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_QueryValue *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_ReplaceKey 
*/
static NTSTATUS winreg_ReplaceKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_ReplaceKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_RestoreKey 
*/
static NTSTATUS winreg_RestoreKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_RestoreKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_SaveKey 
*/
static NTSTATUS winreg_SaveKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_SaveKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_SetKeySecurity 
*/
static NTSTATUS winreg_SetKeySecurity(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_SetKeySecurity *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_SetValue 
*/
static NTSTATUS winreg_SetValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_SetValue *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_UnLoadKey 
*/
static NTSTATUS winreg_UnLoadKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_UnLoadKey *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_InitiateSystemShutdown 
*/
static NTSTATUS winreg_InitiateSystemShutdown(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_InitiateSystemShutdown *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_AbortSystemShutdown 
*/
static NTSTATUS winreg_AbortSystemShutdown(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_AbortSystemShutdown *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_GetVersion 
*/
static NTSTATUS winreg_GetVersion(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_GetVersion *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKCC 
*/
static NTSTATUS winreg_OpenHKCC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKCC *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKDD 
*/
static NTSTATUS winreg_OpenHKDD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKDD *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_QueryMultipleValues 
*/
static NTSTATUS winreg_QueryMultipleValues(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_QueryMultipleValues *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_InitiateSystemShutdownEx 
*/
static NTSTATUS winreg_InitiateSystemShutdownEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_InitiateSystemShutdownEx *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_SaveKeyEx 
*/
static NTSTATUS winreg_SaveKeyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_SaveKeyEx *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKPT 
*/
static NTSTATUS winreg_OpenHKPT(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKPT *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_OpenHKPN 
*/
static NTSTATUS winreg_OpenHKPN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_OpenHKPN *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* 
  winreg_QueryMultipleValues2 
*/
static NTSTATUS winreg_QueryMultipleValues2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
		       struct winreg_QueryMultipleValues2 *r)
{
	return NT_STATUS_NOT_IMPLEMENTED;
}


/* include the generated boilerplate */
#include "librpc/gen_ndr/ndr_winreg_s.c"