s3:registry: refactor deletion of various subkey lists out of regdb_store_keys()
authorMichael Adam <obnox@samba.org>
Thu, 26 Feb 2009 00:43:58 +0000 (01:43 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 19 Mar 2009 17:04:00 +0000 (18:04 +0100)
Micheal

Signed-off-by: Michael Adam <obnox@samba.org>
source/registry/reg_backend_db.c

index e66b510d8f237fd6d4941bd82aaad1bad8dd0115..7742eeb011b1b0559b47947800503306c92c64bd 100644 (file)
@@ -565,6 +565,35 @@ static WERROR regdb_delete_subkeylist(const char *keyname)
        return regdb_delete_key_with_prefix(keyname, NULL);
 }
 
+static WERROR regdb_delete_key_lists(const char *keyname)
+{
+       WERROR werr;
+
+       werr = regdb_delete_values(keyname);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+                         REG_VALUE_PREFIX, keyname, dos_errstr(werr)));
+               goto done;
+       }
+
+       werr = regdb_delete_secdesc(keyname);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+                         REG_SECDESC_PREFIX, keyname, dos_errstr(werr)));
+               goto done;
+       }
+
+       werr = regdb_delete_subkeylist(keyname);
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(1, (__location__ " Deleting %s failed: %s\n",
+                         keyname, dos_errstr(werr)));
+               goto done;
+       }
+
+done:
+       return werr;
+}
+
 /***********************************************************************
  Add subkey strings to the registry tdb under a defined key
  fmt is the same format as tdb_pack except this function only supports
@@ -779,37 +808,9 @@ bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
                if (!path) {
                        goto cancel;
                }
-               path = normalize_reg_path(ctx, path);
-               if (!path) {
-                       goto cancel;
-               }
-
-               /* (a) Delete the value list for this key */
-
-               werr = regdb_delete_values(path);
-               if (!W_ERROR_IS_OK(werr)) {
-                       DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
-                                 REG_VALUE_PREFIX, path, dos_errstr(werr)));
-                       goto cancel;
-               }
 
-               /* (b) Delete the secdesc for this key */
-
-               werr = regdb_delete_secdesc(path);
-               if (!W_ERROR_IS_OK(werr)) {
-                       DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
-                                 REG_SECDESC_PREFIX, path, dos_errstr(werr)));
-                       goto cancel;
-               }
-
-               /* (c) Delete the list of subkeys of this key */
-
-               werr = regdb_delete_subkeylist(path);
-               if (!W_ERROR_IS_OK(werr)) {
-                       DEBUG(1, (__location__ " Deleting %s failed: %s\n",
-                                 path, dos_errstr(werr)));
-                       goto cancel;
-               }
+               werr = regdb_delete_key_lists(path);
+               W_ERROR_NOT_OK_GOTO(werr, cancel);
 
                TALLOC_FREE(path);
        }