r3367: More registry updates.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 29 Oct 2004 11:44:59 +0000 (11:44 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:02 +0000 (13:05 -0500)
Add support flush_key and close_hive.

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

index a9f7bf1d5fb3342d63abc07c1483b2ad4022bce7..999203f4d1c9ff42b80e7f90a123642173845c49 100644 (file)
@@ -157,6 +157,19 @@ WERROR reg_open(struct registry_context **ret, const char *backend, const char *
        return WERR_OK;
 }
 
+WERROR reg_close (struct registry_context *ctx)
+{
+       int i;
+       for (i = 0; i < ctx->num_hives; i++) {
+               if (ctx->hives[i]->functions->close_hive) {
+                       ctx->hives[i]->functions->close_hive(ctx->hives[i]);
+               }
+       }
+       talloc_destroy(ctx);
+
+       return WERR_OK;
+}
+
 /* Open a registry file/host/etc */
 WERROR reg_import_hive(struct registry_context *h, const char *backend, const char *location, const char *credentials, const char *hivename)
 {
@@ -367,7 +380,8 @@ WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx, struct registry_key *key,
 
        if(key->hive->functions->get_subkey_by_name) {
                error = key->hive->functions->get_subkey_by_name(mem_ctx, key,name,subkey);
-               /* FIXME: Fall back to reg_open_key rather then get_subkey_by_index */
+       } else if(key->hive->functions->open_key) {
+               error = key->hive->functions->open_key(mem_ctx, key->hive, talloc_asprintf(mem_ctx, "%s\\%s", key->path, name), subkey);
        } else if(key->hive->functions->get_subkey_by_index) {
                for(i = 0; W_ERROR_IS_OK(error); i++) {
                        error = reg_key_get_subkey_by_index(mem_ctx, key, i, subkey);
@@ -589,9 +603,8 @@ WERROR reg_del_value(struct registry_value *val)
        return ret;
 }
 
-WERROR reg_save(struct registry_context *h, const char *location)
+WERROR reg_save (struct registry_context *ctx, const char *location)
 {
-       /* FIXME */     
        return WERR_NOT_SUPPORTED;
 }
 
@@ -615,3 +628,17 @@ WERROR reg_key_get_parent(TALLOC_CTX *mem_ctx, struct registry_key *key, struct
        SAFE_FREE(parent_name);
        return error;
 }
+
+WERROR reg_key_flush(struct registry_key *key)
+{
+       if (!key) {
+               return WERR_INVALID_PARAM;
+       }
+       
+       if (key->hive->functions->flush_key) {
+               return key->hive->functions->flush_key(key);
+       }
+       
+       /* No need for flushing, apparently */
+       return WERR_OK;
+}
index a18bed5591d7e5e1b1044d70cba6fb670779da18..bd3afbdedf2e197be55846f40202807dd56c3ce6 100644 (file)
@@ -194,11 +194,18 @@ static WERROR ldb_del_key (struct registry_key *key)
        return WERR_OK;
 }
 
+static WERROR ldb_close_hive (struct registry_hive *hive)
+{
+       ldb_close (hive->backend_data);
+       return WERR_OK;
+}
+
 static struct registry_operations reg_backend_ldb = {
        .name = "ldb",
        .add_key = ldb_add_key,
        .del_key = ldb_del_key,
        .open_hive = ldb_open_hive,
+       .close_hive = ldb_close_hive,
        .open_key = ldb_open_key,
        .get_value_by_index = ldb_get_value_by_id,
        .get_subkey_by_index = ldb_get_subkey_by_id,
index 5ed03c062c28bf07c964473cee5d8dc28ab40688..31e55bc9a3a47aa8aeaa1422b233a78ef7d984db 100644 (file)
@@ -97,6 +97,12 @@ static WERROR rpc_list_hives (TALLOC_CTX *mem_ctx, const char *location, const c
        return WERR_OK;
 }
 
+static WERROR rpc_close_hive (struct registry_hive *h)
+{
+       dcerpc_pipe_close(h->backend_data);
+       return WERR_OK;
+}
+
 static WERROR rpc_open_hive(TALLOC_CTX *mem_ctx, struct registry_hive *h, struct registry_key **k)
 {
        NTSTATUS status;
@@ -373,6 +379,7 @@ static WERROR rpc_num_subkeys(struct registry_key *key, int *count) {
 static struct registry_operations reg_backend_rpc = {
        .name = "rpc",
        .open_hive = rpc_open_hive,
+       .close_hive = rpc_close_hive,
        .open_key = rpc_open_key,
        .get_subkey_by_index = rpc_get_subkey_by_index,
        .get_value_by_index = rpc_get_value_by_index,
index 9ef696d6aa0a1a40d09ce938b3d385ea27d4eb68..0a071ef7413e3eda80b1086833c008d9373c3b19 100644 (file)
@@ -27,7 +27,7 @@ enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
 
 static void winreg_destroy_hive(struct dcesrv_connection *c, struct dcesrv_handle *h)
 {
-       /* FIXME: Free ((struct registry_key *)h->data)->root->hive->reg_ctx */
+       reg_close(((struct registry_key *)h->data)->hive->reg_ctx);
 }
 
 static WERROR winreg_openhive (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, const char *hivename, struct policy_handle **outh)
@@ -208,7 +208,12 @@ static WERROR winreg_EnumValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
 static WERROR winreg_FlushKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct winreg_FlushKey *r)
 {
-       return WERR_NOT_SUPPORTED;
+       struct dcesrv_handle *h;
+
+       h = dcesrv_handle_fetch(dce_call->conn, r->in.handle, HTYPE_REGKEY);
+       DCESRV_CHECK_HANDLE(h);
+
+       return reg_key_flush(h->data);
 }