diff options
author | Michael Adam <obnox@samba.org> | 2009-02-26 02:56:00 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-02-26 13:22:55 +0100 |
commit | b5fbe06d746f3e5f004b7006812014dfd269c250 (patch) | |
tree | 9f7bdb58e679f7ed4e10a3863f11903b0230df46 /source3/registry | |
parent | 97508eefb78598fcf15c07b4c0cb92dbf21c30f7 (diff) | |
download | samba-b5fbe06d746f3e5f004b7006812014dfd269c250.tar.gz samba-b5fbe06d746f3e5f004b7006812014dfd269c250.tar.bz2 samba-b5fbe06d746f3e5f004b7006812014dfd269c250.zip |
s3:registry: implement delete_subkey in the db backend
Michael
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_backend_db.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 852e54f69d..30f1db9c53 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -957,6 +957,73 @@ done: return werr; } +static WERROR regdb_delete_subkey(const char *key, const char *subkey) +{ + WERROR werr, werr2; + struct regsubkey_ctr *subkeys; + char *path; + TALLOC_CTX *mem_ctx = talloc_stackframe(); + + if (!regdb_key_is_base_key(key) && !regdb_key_exists(key)) { + werr = WERR_NOT_FOUND; + goto done; + } + + path = talloc_asprintf(mem_ctx, "%s/%s", key, subkey); + if (path == NULL) { + werr = WERR_NOMEM; + goto done; + } + + if (!regdb_key_exists(path)) { + werr = WERR_OK; + goto done; + } + + werr = regdb_transaction_start(); + W_ERROR_NOT_OK_GOTO_DONE(werr); + + werr = regdb_delete_key_lists(path); + W_ERROR_NOT_OK_GOTO(werr, cancel); + + werr = regsubkey_ctr_init(mem_ctx, &subkeys); + W_ERROR_NOT_OK_GOTO(werr, cancel); + + if (regdb_fetch_keys(key, subkeys) < 0) { + werr = WERR_REG_IO_FAILURE; + goto cancel; + } + + werr = regsubkey_ctr_delkey(subkeys, subkey); + W_ERROR_NOT_OK_GOTO(werr, cancel); + + if (!regdb_store_keys_internal(key, subkeys)) { + DEBUG(0, (__location__ " failed to store new subkey_list for " + "parent key %s\n", key)); + werr = WERR_REG_IO_FAILURE; + goto cancel; + } + + werr = regdb_transaction_commit(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, (__location__ " failed to commit transaction: %s\n", + win_errstr(werr))); + } + + goto done; + +cancel: + werr2 = regdb_transaction_cancel(); + if (!W_ERROR_IS_OK(werr2)) { + DEBUG(0, (__location__ " failed to cancel transaction: %s\n", + win_errstr(werr2))); + } + +done: + talloc_free(mem_ctx); + return werr; +} + static TDB_DATA regdb_fetch_key_internal(TALLOC_CTX *mem_ctx, const char *key) { char *path = NULL; @@ -1606,6 +1673,7 @@ REGISTRY_OPS regdb_ops = { .store_subkeys = regdb_store_keys, .store_values = regdb_store_values, .create_subkey = regdb_create_subkey, + .delete_subkey = regdb_delete_subkey, .get_secdesc = regdb_get_secdesc, .set_secdesc = regdb_set_secdesc, .subkeys_need_update = regdb_subkeys_need_update, |