summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c53
-rw-r--r--source4/lib/registry/tools/regtree.c2
-rw-r--r--source4/librpc/idl/winreg.idl15
-rw-r--r--source4/torture/rpc/winreg.c54
4 files changed, 96 insertions, 28 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 f5a7127ed6..472a851638 100644
--- a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
+++ b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
@@ -75,6 +75,8 @@ struct rpc_key_data {
struct policy_handle pol;
int num_subkeys;
int num_values;
+ int max_valnamelen;
+ int max_valdatalen;
};
struct {
@@ -194,6 +196,54 @@ static WERROR rpc_open_key(REG_HANDLE *h, const char *name, REG_KEY **key)
return rpc_key_put_rpc_data(*key, &mykeydata);
}
+static WERROR rpc_get_value_by_index(REG_KEY *parent, int n, REG_VAL **value)
+{
+ struct winreg_EnumValue r;
+ struct winreg_Uint8buf vb;
+ struct winreg_Uint16buf bn;
+ struct rpc_data *mydata = parent->handle->backend_data;
+ struct winreg_EnumValueName vn;
+ NTSTATUS status;
+ struct rpc_key_data *mykeydata = parent->backend_data;
+ uint32 type = 0x0, requested_len = 0, returned_len = 0;
+
+ /* FIXME */
+
+ r.in.handle = &mykeydata->pol;
+ r.in.enum_index = n;
+ r.in.type = r.out.type = &type;
+ r.in.requested_len = r.out.requested_len = &requested_len;
+ r.in.returned_len = r.out.returned_len = &returned_len;
+ bn.max_len = mykeydata->max_valnamelen*3;
+ bn.offset = 0;
+ bn.len = 0;
+ bn.buffer = NULL;
+ vn.max_len = mykeydata->max_valnamelen*3;
+ vn.buf = &bn;
+ r.in.name = r.out.name = &vn;
+ vb.max_len = mykeydata->max_valdatalen*3;
+ vb.offset = 0x0;
+ vb.len = 0x0;
+ vb.buffer = NULL;
+ r.in.value = r.out.value = &vb;
+
+ status = dcerpc_winreg_EnumValue(mydata->pipe, parent->mem_ctx, &r);
+ if(NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status)));
+ }
+
+ if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
+ *value = reg_val_new(parent, NULL);
+ (*value)->name = (char *)r.out.name->buf->buffer;
+ (*value)->data_type = type;
+ (*value)->data_len = r.out.value->len;
+ (*value)->data_blk = r.out.value->buffer;
+ return WERR_OK;
+ }
+
+ return r.out.result;
+}
+
static WERROR rpc_get_subkey_by_index(REG_KEY *parent, int n, REG_KEY **subkey)
{
struct winreg_EnumKey r;
@@ -269,6 +319,8 @@ static WERROR rpc_query_key(REG_KEY *k)
if (W_ERROR_IS_OK(r.out.result)) {
mykeydata->num_subkeys = r.out.num_subkeys;
mykeydata->num_values = r.out.num_values;
+ mykeydata->max_valnamelen = r.out.max_valnamelen;
+ mykeydata->max_valdatalen = r.out.max_valbufsize;
}
return r.out.result;
@@ -355,6 +407,7 @@ static struct registry_ops reg_backend_rpc = {
.open_root_key = rpc_open_root,
.open_key = rpc_open_key,
.get_subkey_by_index = rpc_get_subkey_by_index,
+ .get_value_by_index = rpc_get_value_by_index,
.add_key = rpc_add_key,
.del_key = rpc_del_key,
.free_key_backend_data = rpc_close_key,
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index eb32b1e55e..3e74db2557 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -53,7 +53,7 @@ void print_tree(int l, REG_KEY *p, int fullpath, int novals)
}
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- DEBUG(0, ("Error occured while fetching subkeys for '%s'\n", reg_key_get_path(p)));
+ DEBUG(0, ("Error occured while fetching values for '%s': %s\n", reg_key_get_path(p), win_errstr(error)));
}
}
}
diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl
index 539889b515..2fb30411d4 100644
--- a/source4/librpc/idl/winreg.idl
+++ b/source4/librpc/idl/winreg.idl
@@ -126,6 +126,19 @@
uint32 max_len;
uint32 offset;
uint32 len;
+ uint16 buffer[len];
+ } winreg_Uint16buf;
+
+ typedef struct {
+ uint16 len;
+ uint16 max_len;
+ winreg_Uint16buf *buf;
+ } winreg_EnumValueName;
+
+ typedef struct {
+ uint32 max_len;
+ uint32 offset;
+ uint32 len;
uint8 buffer[len];
} winreg_Uint8buf;
@@ -134,7 +147,7 @@
WERROR winreg_EnumValue(
[in,ref] policy_handle *handle,
[in] uint32 enum_index,
- [in,out,ref] winreg_String *name,
+ [in,out,ref] winreg_EnumValueName *name,
[in,out] uint32 *type,
[in,out] winreg_Uint8buf *value,
[in,out] uint32 *requested_len,
diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index 3864de6503..3323ea5d35 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -262,40 +262,42 @@ static BOOL test_EnumKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
static BOOL test_EnumValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *handle)
+ struct policy_handle *handle, int max_valnamelen, int max_valbufsize)
{
struct winreg_EnumValue r;
- struct winreg_Uint8buf value;
- struct winreg_String name;
- uint32 type, requested_len, returned_len;
+ struct winreg_Uint8buf vb;
+ struct winreg_EnumValueName vn;
+ uint32 type = 0, requested_len = 0, returned_len = 0;
NTSTATUS status;
- r.in.handle = handle;
- r.in.enum_index = 0;
-
- init_winreg_String(&name, NULL);
- r.in.name = r.out.name = &name;
-
- type = 0;
- r.in.type = &type;
-
- value.max_len = 0xffff;
- value.offset = 0;
- value.len = 0;
- value.buffer = NULL;
-
- r.in.value = &value;
-
- requested_len = value.max_len;
- r.in.requested_len = &requested_len;
- returned_len = 0;
- r.in.returned_len = &returned_len;
+ r.in.handle = handle;
+ r.in.enum_index = 0;
+ r.in.type = &type;
+ r.in.requested_len = &requested_len;
+ r.in.returned_len = &returned_len;
+ vn.max_len = max_valnamelen;
+ vn.len = 0;
+ vn.buf = NULL;
+ r.in.name = r.out.name = &vn;
+ vb.max_len = max_valbufsize;
+ vb.offset = 0x0;
+ vb.len = 0x0;
+ vb.buffer = NULL;
+ r.in.value = &vb;
do {
-
status = dcerpc_winreg_EnumValue(p, mem_ctx, &r);
+ if(NT_STATUS_IS_ERR(status)) {
+ printf("EnumValue failed - %s\n", nt_errstr(status));
+ return False;
+ }
r.in.enum_index++;
} while (W_ERROR_IS_OK(r.out.result));
+
+ if(!W_ERROR_EQUAL(r.out.result, WERR_NO_MORE_ITEMS)) {
+ printf("EnumValue failed - %s\n", win_errstr(r.out.result));
+ return False;
+ }
return True;
}
@@ -466,7 +468,7 @@ static BOOL test_key(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
if (!test_EnumKey(p, mem_ctx, handle, depth)) {
}
- if (!test_EnumValue(p, mem_ctx, handle)) {
+ if (!test_EnumValue(p, mem_ctx, handle, 200, 200)) {
}
/* Enumerate values */