diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-04-05 20:44:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:50:41 -0500 |
commit | b96025eb15e3648e77e0e6aa343e23ca2f1156da (patch) | |
tree | de172e59aa322f1f015f941ca6cc8c5ff596777d | |
parent | 220ea5b6e6e4d049cb80c1c206ead6021b807283 (diff) | |
download | samba-b96025eb15e3648e77e0e6aa343e23ca2f1156da.tar.gz samba-b96025eb15e3648e77e0e6aa343e23ca2f1156da.tar.bz2 samba-b96025eb15e3648e77e0e6aa343e23ca2f1156da.zip |
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 used to be commit ae2b63b6f1821bc4f693cb8e2a5f78718c483c24)
-rw-r--r-- | source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c | 19 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/handles.c | 2 | ||||
-rw-r--r-- | source4/rpc_server/winreg/rpc_winreg.c | 47 | ||||
-rw-r--r-- | source4/torture/rpc/winreg.c | 23 |
5 files changed, 88 insertions, 5 deletions
diff --git a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c index 75d5a95187..afa60c5c4a 100644 --- a/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c +++ b/source4/lib/registry/reg_backend_ldb/reg_backend_ldb.c @@ -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) diff --git a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c index 84c3cb8aee..ad4d537f9b 100644 --- a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c @@ -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; diff --git a/source4/rpc_server/handles.c b/source4/rpc_server/handles.c index 043318c075..611dc42f76 100644 --- a/source4/rpc_server/handles.c +++ b/source4/rpc_server/handles.c @@ -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)); diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c index 2787c07847..e5658abb09 100644 --- a/source4/rpc_server/winreg/rpc_winreg.c +++ b/source4/rpc_server/winreg/rpc_winreg.c @@ -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; } diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 23e3d2e779..41804d3302 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -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) { |