diff options
author | Günther Deschner <gd@samba.org> | 2007-09-27 01:26:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:31:01 -0500 |
commit | 4d7a1c3bcfca8261d30ad902444eda31a6b0e2b6 (patch) | |
tree | 7bdef81b771ba0c43561fce1376ee52ffc5b5bce | |
parent | 3d4af73f50660d448e7c60ca791165d6a4fe36d4 (diff) | |
download | samba-4d7a1c3bcfca8261d30ad902444eda31a6b0e2b6.tar.gz samba-4d7a1c3bcfca8261d30ad902444eda31a6b0e2b6.tar.bz2 samba-4d7a1c3bcfca8261d30ad902444eda31a6b0e2b6.zip |
r25370: Allow to delete registry keys recursively without deleting the final key.
Guenther
(This used to be commit e9922cd8aeb70aebb162ad598fda76ad69226b94)
-rw-r--r-- | source3/registry/reg_api.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 1d863ec93e..93ac8a9c2a 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -701,15 +701,15 @@ WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path, return WERR_OK; } - /* * Utility function to delete a registry key with all its subkeys. * Note that reg_deletekey returns ACCESS_DENIED when called on a * key that has subkeys. */ -WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, - struct registry_key *parent, - const char *path) +WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx, + struct registry_key *parent, + const char *path, + BOOL del_key) { TALLOC_CTX *mem_ctx = NULL; WERROR werr = WERR_OK; @@ -731,21 +731,42 @@ WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, while (W_ERROR_IS_OK(werr = reg_enumkey(mem_ctx, key, 0, &subkey_name, NULL))) { - werr = reg_deletekey_recursive(mem_ctx, key, subkey_name); + werr = reg_deletekey_recursive_internal(mem_ctx, key, + subkey_name, + True); if (!W_ERROR_IS_OK(werr)) { goto done; } } if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) { - DEBUG(1, ("reg_deletekey_recursive: Error enumerating " - "subkeys: %s\n", dos_errstr(werr))); + DEBUG(1, ("reg_deletekey_recursive_internal: " + "Error enumerating subkeys: %s\n", + dos_errstr(werr))); goto done; } - /* now delete the actual key */ - werr = reg_deletekey(parent, path); - + werr = WERR_OK; + + if (del_key) { + /* now delete the actual key */ + werr = reg_deletekey(parent, path); + } + done: TALLOC_FREE(mem_ctx); return werr; } + +WERROR reg_deletekey_recursive(TALLOC_CTX *ctx, + struct registry_key *parent, + const char *path) +{ + return reg_deletekey_recursive_internal(ctx, parent, path, True); +} + +WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx, + struct registry_key *parent, + const char *path) +{ + return reg_deletekey_recursive_internal(ctx, parent, path, False); +} |