s3:registry: add regdb_create_basekey()
authorMichael Adam <obnox@samba.org>
Mon, 4 Jul 2011 11:14:43 +0000 (13:14 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 4 Jul 2011 18:02:08 +0000 (20:02 +0200)
Function to create a base key in the registry db, i.e. one that
has no parent key.

Pair-Programmed-With: Gregor Beck <gbeck@sernet.de>

source3/registry/reg_backend_db.c

index 84ac57216b1058927c028188467a0222c98fce38..e5386f7d918d0d7bd04276dcf0caf81cd8bbf8c7 100644 (file)
@@ -50,6 +50,7 @@ static bool regdb_store_values_internal(struct db_context *db, const char *key,
                                        struct regval_ctr *values);
 
 static NTSTATUS create_sorted_subkeys(const char *key);
+static WERROR regdb_create_basekey(struct db_context *db, const char *key);
 
 /* List the deepest path into the registry.  All part components will be created.*/
 
@@ -1187,6 +1188,41 @@ static WERROR regdb_create_subkey(const char *key, const char *subkey)
        return regdb_create_subkey_internal(regdb, key, subkey);
 }
 
+/**
+ * create a base key
+ */
+
+struct regdb_create_basekey_context {
+       const char *key;
+};
+
+static NTSTATUS regdb_create_basekey_action(struct db_context *db,
+                                           void *private_data)
+{
+       WERROR werr;
+       struct regdb_create_basekey_context *create_ctx;
+
+       create_ctx = (struct regdb_create_basekey_context *)private_data;
+
+       werr = regdb_store_subkey_list(db, NULL, create_ctx->key);
+
+       return werror_to_ntstatus(werr);
+}
+
+static WERROR regdb_create_basekey(struct db_context *db, const char *key)
+{
+       WERROR werr;
+       struct regdb_create_subkey_context create_ctx;
+
+       create_ctx.key = key;
+
+       werr = ntstatus_to_werror(dbwrap_trans_do(db,
+                                                 regdb_create_basekey_action,
+                                                 &create_ctx));
+
+       return werr;
+}
+
 /**
  * create a subkey of a given key
  */