registry: change order of deleting value and subkey lists in store_keys().
authorMichael Adam <obnox@samba.org>
Thu, 8 May 2008 15:59:32 +0000 (17:59 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 8 May 2008 16:29:10 +0000 (18:29 +0200)
Next step in the plan to make store_keys safer without transactions.

Michael
(This used to be commit f7c8718dead63964481954a86427b8c05d15452c)

source3/registry/reg_backend_db.c

index b729e58dafa73349fe8a3a38991e34efb9b44024..c0ee8017c143320aaf6e047b29b21e225900ec9f 100644 (file)
@@ -671,7 +671,10 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
                        continue;
                }
 
                        continue;
                }
 
-               path = talloc_asprintf(ctx, "%s/%s", key, oldkeyname);
+               path = talloc_asprintf(ctx, "%s/%s/%s",
+                               REG_VALUE_PREFIX,
+                               key,
+                               oldkeyname );
                if (!path) {
                        goto cancel;
                }
                if (!path) {
                        goto cancel;
                }
@@ -679,17 +682,11 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
                if (!path) {
                        goto cancel;
                }
                if (!path) {
                        goto cancel;
                }
-               status = dbwrap_delete_bystring(regdb, path);
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(1, ("Deleting %s failed\n", path));
-                       goto cancel;
-               }
-
+               /* Ignore errors here, we might have no values around */
+               dbwrap_delete_bystring(regdb, path);
                TALLOC_FREE(path);
                TALLOC_FREE(path);
-               path = talloc_asprintf(ctx, "%s/%s/%s",
-                               REG_VALUE_PREFIX,
-                               key,
-                               oldkeyname );
+
+               path = talloc_asprintf(ctx, "%s/%s", key, oldkeyname);
                if (!path) {
                        goto cancel;
                }
                if (!path) {
                        goto cancel;
                }
@@ -697,11 +694,11 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
                if (!path) {
                        goto cancel;
                }
                if (!path) {
                        goto cancel;
                }
-
-               /*
-                * Ignore errors here, we might have no values around
-                */
-               dbwrap_delete_bystring(regdb, path);
+               status = dbwrap_delete_bystring(regdb, path);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(1, ("Deleting %s failed\n", path));
+                       goto cancel;
+               }
                TALLOC_FREE(path);
        }
 
                TALLOC_FREE(path);
        }