s3:registry: add new mode to regdb_store_subkey_list() for handing in NULL parent key
authorMichael Adam <obnox@samba.org>
Mon, 4 Jul 2011 11:06:20 +0000 (13:06 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 9 Aug 2011 14:57:54 +0000 (16:57 +0200)
Standard behaviour is to concatenate parent and key path (parent\key).
This new mode allows for storing subkey lists for base keys using a NULL
parent argument.

Pair-Programmed-With: Gregor Beck <gbeck@sernet.de>
(cherry picked from commit 15a50ef8f856d83508ece3a8294dfaffbadc3b41)

source3/registry/reg_backend_db.c

index 17731317cbb8732c0711d7d25d29732eefe5d36b..6e3db5d5c96ea33d2c15a878102400d2f76f6d09 100644 (file)
@@ -857,6 +857,8 @@ done:
  * Utility function to store a new empty list of
  * subkeys of given key specified as parent and subkey name
  * (thereby creating the key).
+ * If the parent keyname is NULL, then the "subkey" is
+ * interpreted as a base key.
  * If the subkey list does already exist, it is not modified.
  *
  * Must be called from within a transaction.
@@ -869,7 +871,11 @@ static WERROR regdb_store_subkey_list(struct db_context *db, const char *parent,
        struct regsubkey_ctr *subkeys = NULL;
        TALLOC_CTX *frame = talloc_stackframe();
 
-       path = talloc_asprintf(frame, "%s\\%s", parent, key);
+       if (parent == NULL) {
+               path = talloc_strdup(frame, key);
+       } else {
+               path = talloc_asprintf(frame, "%s\\%s", parent, key);
+       }
        if (!path) {
                werr = WERR_NOMEM;
                goto done;