r3340: Various fixes in the registry code. Implement the EnumKey call
authorJelmer Vernooij <jelmer@samba.org>
Thu, 28 Oct 2004 23:06:12 +0000 (23:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:04:57 +0000 (13:04 -0500)
in the server.

source/lib/registry/common/reg_interface.c
source/lib/registry/reg_backend_ldb/reg_backend_ldb.c
source/lib/registry/reg_backend_rpc/reg_backend_rpc.c
source/rpc_server/winreg/rpc_winreg.c
source/torture/rpc/winreg.c

index 16edadfcbb468c74ab23dd0798e25783bd542a93..6237a788b75d292e97736864bf9d1628076b2845 100644 (file)
@@ -191,7 +191,10 @@ WERROR reg_import_hive(struct registry_context *h, const char *backend, const ch
 
        if(!W_ERROR_IS_OK(werr)) return werr;
        
-       if(!ret->root) return WERR_GENERAL_FAILURE;
+       if(!ret->root) {
+               DEBUG(0, ("Backend %s didn't provide root key!\n", backend));
+               return WERR_GENERAL_FAILURE;
+       }
 
        ret->root->hive = ret;
        ret->root->name = NULL;
index faa8a5e62c90b866f7fe2c4c4827c445338392d7..b26ee6ec60b4e0c4b400db257e6366cbf5cd4376 100644 (file)
@@ -146,7 +146,10 @@ static WERROR ldb_open_hive(TALLOC_CTX *mem_ctx, struct registry_hive *hive, str
        ldb_set_debug_stderr(c);
        hive->backend_data = c;
 
-       return ldb_open_key(mem_ctx, hive, "", k);
+       hive->root = talloc_zero_p(mem_ctx, struct registry_key);
+       hive->root->name = talloc_strdup(mem_ctx, "");
+
+       return WERR_OK;
 }
 
 static struct registry_operations reg_backend_ldb = {
index 76c19d01adbaea1cd38ace1c1f288ea9757e1967..5ed03c062c28bf07c964473cee5d8dc28ab40688 100644 (file)
@@ -85,7 +85,7 @@ struct {
 
 static WERROR rpc_query_key(struct registry_key *k);
 
-WERROR rpc_list_hives (TALLOC_CTX *mem_ctx, const char *location, const char *credentials, char ***hives)
+static WERROR rpc_list_hives (TALLOC_CTX *mem_ctx, const char *location, const char *credentials, char ***hives)
 {
        int i = 0;
        *hives = talloc_p(mem_ctx, char *);
index fc6e426152dbbe8ba377e2ddcf4233b59ecd787b..6fa42d2bcd0eafcdaa37ad088ec3dae6a31622c7 100644 (file)
@@ -177,7 +177,15 @@ static WERROR winreg_EnumKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem
        h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
        DCESRV_CHECK_HANDLE(h);
 
-       key = h->data;
+       r->out.result = reg_key_get_subkey_by_index(mem_ctx, (struct registry_key *)h->data, r->in.enum_index, &key);
+
+       if (W_ERROR_IS_OK(r->out.result)) {
+               r->out.key_name_len = strlen(key->name);
+               r->out.out_name = talloc_zero_p(mem_ctx, struct winreg_EnumKeyNameResponse);
+               r->out.out_name->name = key->name;
+               r->out.class = talloc_zero_p(mem_ctx, struct winreg_String);
+               r->out.last_changed_time = talloc_zero_p(mem_ctx, struct winreg_Time);
+       }
        
        return WERR_NOT_SUPPORTED;
 }
index 3fdb546a098cb9bf6de6a63869e14b02fe7bfa12..1ca57686224ea5934d6b95cb78149af665d697b1 100644 (file)
@@ -51,6 +51,11 @@ static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("GetVersion failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
        return True;
 }
 
@@ -106,6 +111,11 @@ static BOOL test_CloseKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                return False;
        }
 
+       if (!W_ERROR_IS_OK(r.out.result)) {
+               printf("CloseKey failed - %s\n", win_errstr(r.out.result));
+               return False;
+       }
+
        return True;
 }
 
@@ -228,6 +238,8 @@ static BOOL test_EnumKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        struct winreg_Time tm;
        NTSTATUS status;
 
+       printf("Testing EnumKey\n\n");
+
        r.in.handle = handle;
        r.in.enum_index = 0;
        r.in.key_name_len = r.out.key_name_len = 0;