1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

r61: - Implement first call in the winreg rpc server

- Add some initial implementation of the ldb backend
- More checks in the winreg torture test
This commit is contained in:
Jelmer Vernooij 2004-04-05 20:44:33 +00:00 committed by Gerald (Jerry) Carter
parent ae97f5f50b
commit ae2b63b6f1
5 changed files with 88 additions and 5 deletions

View File

@ -43,9 +43,25 @@ static BOOL ldb_close_registry(REG_HANDLE *h)
return True;
}
static BOOL ldb_fetch_subkeys(REG_KEY *k, int *count, REG_KEY ***subkeys)
{
ldb_search();
}
static REG_KEY *ldb_open_key(REG_HANDLE *h, const char *name)
{
/* FIXME */
struct ldb_context *c = h->backend_data;
char *path;
struct ldb_message **msg;
REG_KEY *key = NULL;
(dn=key=Systems,
if(ldb_search(c, NULL, LDP_SCOPE_BASE, "", NULL,&msg) > 0) {
key = reg_key_new_abs(name, h, base);
}
ldap_search_free(c, msg);
return key;
}
static REG_OPS reg_backend_ldb = {
@ -53,6 +69,7 @@ static REG_OPS reg_backend_ldb = {
.open_registry = ldb_open_registry,
.close_registry = ldb_close_registry,
.open_key = ldb_open_key,
.fetch_subkeys = ldb_fetch_subkeys,
};
NTSTATUS reg_ldb_init(void)

View File

@ -90,7 +90,7 @@ static BOOL rpc_open_registry(REG_HANDLE *h, const char *location, BOOL try_full
DCERPC_WINREG_UUID,
DCERPC_WINREG_VERSION,
lp_workgroup(),
"jelwin", "dds");
"tridge", "samba");
if(!NT_STATUS_IS_OK(status)) return False;

View File

@ -32,7 +32,7 @@ struct dcesrv_handle *dcesrv_handle_new(struct dcesrv_connection *dce_conn,
struct dcesrv_handle *h;
mem_ctx = talloc_init("rpc handle type %d\n", handle_type);
if (!mem_ctx) {
if (!mem_ctx) {
return NULL;
}
h = talloc(mem_ctx, sizeof(*h));

View File

@ -22,12 +22,39 @@
#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;
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("nt4", "/home/aurelia/jelmer/NTUSER.DAT", False);
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;
}
@ -38,7 +65,20 @@ static NTSTATUS winreg_OpenHKCR(struct dcesrv_call_state *dce_call, TALLOC_CTX *
static NTSTATUS winreg_OpenHKCU(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct winreg_OpenHKCU *r)
{
return NT_STATUS_NOT_IMPLEMENTED;
struct _privatedata *data = dce_call->conn->private;
REG_KEY *k = reg_open_key(reg_get_root(data->registry), "\\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;
}
@ -178,6 +218,11 @@ static NTSTATUS winreg_NotifyChangeKeyValue(struct dcesrv_call_state *dce_call,
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;
}

View File

@ -80,6 +80,11 @@ static BOOL test_CreateKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return False;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("CreateKey failed - %s\n", win_errstr(r.out.result));
return False;
}
return True;
}
@ -166,6 +171,11 @@ static BOOL test_DeleteKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return False;
}
if (!W_ERROR_IS_OK(r.out.result)) {
printf("DeleteKey failed - %s\n", win_errstr(r.out.result));
return False;
}
return True;
}
@ -413,7 +423,7 @@ typedef BOOL winreg_open_fn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
static BOOL test_Open(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, void *fn)
{
struct policy_handle handle;
struct policy_handle handle, newhandle;
BOOL ret = True;
winreg_open_fn *open_fn = (winreg_open_fn *)fn;
@ -435,11 +445,22 @@ static BOOL test_Open(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, void *fn)
ret = False;
}
if (!test_OpenKey(p, mem_ctx, &handle, "spottyfoot", &newhandle)) {
printf("CreateKey failed (OpenKey after Create didn't work)\n");
ret = False;
}
if (!test_DeleteKey(p, mem_ctx, &handle, "spottyfoot")) {
printf("DeleteKey failed\n");
ret = False;
}
if (test_OpenKey(p, mem_ctx, &handle, "spottyfoot", &newhandle)) {
printf("DeleteKey failed (OpenKey after Delete didn't work)\n");
ret = False;
}
/* The HKCR hive has a very large fanout */
if (open_fn == test_OpenHKCR) {