summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-04-05 13:50:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:50:40 -0500
commit2542ed0ac75d545eef3571bfb19fb39a5b71beb3 (patch)
tree7f05c90fae7fe25864a4c2b9ca28b980f1ed9ca4 /source4/lib/registry
parent381a903d00ccbc3e80e8eca533d304fed6c13870 (diff)
downloadsamba-2542ed0ac75d545eef3571bfb19fb39a5b71beb3.tar.gz
samba-2542ed0ac75d545eef3571bfb19fb39a5b71beb3.tar.bz2
samba-2542ed0ac75d545eef3571bfb19fb39a5b71beb3.zip
r46: Add CreateKey function (still working on it)
(This used to be commit 9f13b7c60cc7e6edd095eee96625ee02cd0dd73b)
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c44
1 files changed, 25 insertions, 19 deletions
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 796d957076..84c3cb8aee 100644
--- a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
+++ b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
@@ -39,7 +39,6 @@ static void init_winreg_String(struct winreg_String *name, const char *s)
struct winreg_Open ## u r; \
struct winreg_OpenUnknown unknown; \
struct policy_handle *hnd = malloc(sizeof(struct policy_handle)); \
- TALLOC_CTX *mem_ctx = talloc_init("openhive"); \
\
unknown.unknown0 = 0x84e0; \
unknown.unknown1 = 0x0000; \
@@ -47,13 +46,11 @@ static void init_winreg_String(struct winreg_String *name, const char *s)
r.in.access_required = SEC_RIGHTS_MAXIMUM_ALLOWED; \
r.out.handle = hnd;\
\
- if (!NT_STATUS_IS_OK(dcerpc_winreg_Open ## u(p, mem_ctx, &r))) {\
+ if (!NT_STATUS_IS_OK(dcerpc_winreg_Open ## u(p, h->mem_ctx, &r))) {\
printf("Error executing open\n");\
return NULL;\
}\
\
- talloc_destroy(mem_ctx);\
-\
return hnd;\
}
@@ -83,7 +80,7 @@ struct {
static BOOL rpc_open_registry(REG_HANDLE *h, const char *location, BOOL try_full)
{
BOOL res = True;
- struct rpc_data *mydata = malloc(sizeof(struct rpc_data));
+ struct rpc_data *mydata = talloc(h->mem_ctx, sizeof(struct rpc_data));
char *binding = strdup(location);
NTSTATUS status;
@@ -124,7 +121,7 @@ static struct policy_handle *rpc_get_key_handle(REG_HANDLE *h, const char *path)
char *end = strchr(path+1, '\\');
NTSTATUS status;
struct winreg_OpenKey r;
- struct policy_handle *key_handle = malloc(sizeof(struct policy_handle));
+ struct policy_handle *key_handle = talloc(h->mem_ctx, sizeof(struct policy_handle));
TALLOC_CTX *mem_ctx;
if(end) hivename = strndup(path+1, end-path-1);
@@ -177,17 +174,16 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
struct winreg_Time tm;
struct rpc_data *mydata = parent->handle->backend_data;
int i;
- REG_KEY **ar = malloc(sizeof(REG_KEY *));
+ REG_KEY **ar = talloc(parent->mem_ctx, sizeof(REG_KEY *));
NTSTATUS status = NT_STATUS_OK;
TALLOC_CTX *mem_ctx;
/* List the hives */
if(parent->backend_data == parent->handle->backend_data) {
- REG_KEY **ar = malloc(sizeof(REG_KEY *));
for(i = 0; known_hives[i].name; i++) {
ar[i] = reg_key_new_rel(known_hives[i].name, parent, NULL);
(*count)++;
- ar = realloc(ar, sizeof(REG_KEY *) * ((*count)+1));
+ ar = talloc_realloc(parent->mem_ctx, ar, sizeof(REG_KEY *) * ((*count)+1));
}
*subkeys = ar;
@@ -199,7 +195,6 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
if(!parent->backend_data) return False;
- mem_ctx = talloc_init("enumkey");
(*count) = 0;
r.in.handle = parent->backend_data;
keyname.unknown = 0x0000020a;
@@ -215,11 +210,11 @@ static BOOL rpc_fetch_subkeys(REG_KEY *parent, int *count, REG_KEY ***subkeys)
r.in.enum_index = i;
r.in.unknown = r.out.unknown = 0x0414;
r.in.key_name_len = r.out.key_name_len = 0;
- status = dcerpc_winreg_EnumKey(mydata->pipe, mem_ctx, &r);
+ status = dcerpc_winreg_EnumKey(mydata->pipe, parent->mem_ctx, &r);
if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
ar[(*count)] = reg_key_new_rel(r.out.out_name->name, parent, NULL);
(*count)++;
- ar = realloc(ar, ((*count)+1) * sizeof(REG_KEY *));
+ ar = talloc_realloc(parent->mem_ctx, ar, ((*count)+1) * sizeof(REG_KEY *));
}
}
@@ -271,29 +266,38 @@ static BOOL rpc_fetch_values(REG_KEY *parent, int *count, REG_VAL ***values)
r.in.returned_len = &returned_len;
r.out.result.v = 0;
- mem_ctx = talloc_init("fetchvalues");
while(1) {
- status = dcerpc_winreg_EnumValue(mydata->pipe, mem_ctx, &r);
+ status = dcerpc_winreg_EnumValue(mydata->pipe, parent->mem_ctx, &r);
if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
r.in.enum_index++;
ar[(*count)] = reg_val_new(parent, NULL);
- ar[(*count)]->name = strdup(r.out.name->name);
+ ar[(*count)]->name = talloc_strdup(ar[*count]->mem_ctx, r.out.name->name);
ar[(*count)]->data_type = *r.out.type;
ar[(*count)]->data_len = value.len;
- ar[(*count)]->data_blk = malloc(value.len);
+ ar[(*count)]->data_blk = talloc(ar[*count]->mem_ctx, value.len);
memcpy(ar[(*count)]->data_blk, value.buffer, value.len);
(*count)++;
- ar = realloc(ar, ((*count)+1) * sizeof(REG_VAL *));
+ ar = talloc_realloc(parent->mem_ctx, ar, ((*count)+1) * sizeof(REG_VAL *));
} else break;
}
- talloc_destroy(mem_ctx);
-
*values = ar;
return True;
}
+static BOOL rpc_add_key(REG_KEY *parent, const char *name)
+{
+ /* FIXME */
+ return False;
+}
+
+static BOOL rpc_del_key(REG_KEY *k)
+{
+ /* FIXME */
+ return False;
+}
+
static REG_OPS reg_backend_rpc = {
.name = "rpc",
.open_registry = rpc_open_registry,
@@ -302,6 +306,8 @@ static REG_OPS reg_backend_rpc = {
.open_key = rpc_open_key,
.fetch_subkeys = rpc_fetch_subkeys,
.fetch_values = rpc_fetch_values,
+ .add_key = rpc_add_key,
+ .del_key = rpc_del_key,
};
NTSTATUS reg_rpc_init(void)