r190: More RPC updates
authorJelmer Vernooij <jelmer@samba.org>
Mon, 12 Apr 2004 21:59:41 +0000 (21:59 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:16 +0000 (12:51 -0500)
(This used to be commit 0a67057e9626c1539f964e978537e24544784263)

source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c
source4/lib/registry/tools/regtree.c
source4/librpc/idl/winreg.idl
source4/torture/rpc/winreg.c

index f5a7127ed656bcc710b515bd069f6b137bfdbc89..472a851638ce1cdec343424c26e7d92d8652ead6 100644 (file)
@@ -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,
index eb32b1e55ea6908f44a8b4991b7154559400b96a..3e74db255784735afbf585551b92153224f31dbb 100644 (file)
@@ -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)));
                }
        }
 }
index 539889b515f778fdfdf6613ec9493411bae602eb..2fb30411d431dd4ae23ec2dced9b495909fc3d7c 100644 (file)
                [in,out]    winreg_Time *last_changed_time
        );
 
+       typedef struct {
+               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;
        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,
index 3864de650325d5ed2d67f27389fce976f81d8ae6..3323ea5d35bb0abeb724709f0b96151d35a2e04a 100644 (file)
@@ -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 */