diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-03-03 11:12:20 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-03-03 11:12:20 +1100 |
commit | 4550c3f470c7e6cb1419f318231301df896a5d1c (patch) | |
tree | 8e975d8514a7f8bf105bdb6207074f47f15ccddf /source4/lib/registry/regf.c | |
parent | c20cf59768d585baf4524c54dadba1ec60673894 (diff) | |
parent | a1ff86dbabff836b95a725d81dc6f325bbc20813 (diff) | |
download | samba-4550c3f470c7e6cb1419f318231301df896a5d1c.tar.gz samba-4550c3f470c7e6cb1419f318231301df896a5d1c.tar.bz2 samba-4550c3f470c7e6cb1419f318231301df896a5d1c.zip |
Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-local
(This used to be commit de1784ec4d50f6eec24b1e9e488b5c07833dc1fd)
Diffstat (limited to 'source4/lib/registry/regf.c')
-rw-r--r-- | source4/lib/registry/regf.c | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c index cf3e564c0e..a192f3be4d 100644 --- a/source4/lib/registry/regf.c +++ b/source4/lib/registry/regf.c @@ -1618,10 +1618,55 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name) return WERR_BADFILE; } - if (key->nk->subkeys_offset != -1 || - key->nk->values_offset != -1) { - DEBUG(0, ("Key '%s' is not empty.\n", name)); - return WERR_FILE_EXISTS; + if (key->nk->subkeys_offset != -1) { + char *sk_name; + struct hive_key *sk = (struct hive_key *)key; + int i = key->nk->num_subkeys; + while (i--) { + /* Get subkey information. */ + error = regf_get_subkey_by_index(parent_nk, sk, 0, + (const char **)&sk_name, + NULL, NULL); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Can't retrieve subkey by index.\n")); + return error; + } + + /* Delete subkey. */ + error = regf_del_key(sk, sk_name); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Can't delete key '%s'.\n", sk_name)); + return error; + } + + talloc_free(sk_name); + } + } + + if (key->nk->values_offset != -1) { + char *val_name; + struct hive_key *sk = (struct hive_key *)key; + DATA_BLOB data; + int i = key->nk->num_values; + while (i--) { + /* Get value information. */ + error = regf_get_value(parent_nk, sk, 0, + (const char **)&val_name, + NULL, &data); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Can't retrieve value by index.\n")); + return error; + } + + /* Delete value. */ + error = regf_del_value(sk, val_name); + if (!W_ERROR_IS_OK(error)) { + DEBUG(0, ("Can't delete value '%s'.\n", val_name)); + return error; + } + + talloc_free(val_name); + } } /* Delete it from the subkey list. */ |