diff options
author | Michael Adam <obnox@samba.org> | 2009-02-25 23:13:07 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2009-02-26 13:22:55 +0100 |
commit | 741e902888fe6f6b8109b9bb8ccca48554d00670 (patch) | |
tree | e180fe71e0443a2aac1f2844a5b50dfe4747d756 /source3 | |
parent | 4b444e4ac4ca0a00a01f22f04bcf01e78593c3a9 (diff) | |
download | samba-741e902888fe6f6b8109b9bb8ccca48554d00670.tar.gz samba-741e902888fe6f6b8109b9bb8ccca48554d00670.tar.bz2 samba-741e902888fe6f6b8109b9bb8ccca48554d00670.zip |
s3:registry: streamline reg_deletekey() somewhat.
use W_ERROR_... macros and separate assignments from checks
Michael
Diffstat (limited to 'source3')
-rw-r--r-- | source3/registry/reg_api.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 9f6ed20568..d84acff7c5 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -544,39 +544,36 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent, WERROR reg_deletekey(struct registry_key *parent, const char *path) { WERROR err; - TALLOC_CTX *mem_ctx; char *name, *end; struct registry_key *tmp_key, *key; + TALLOC_CTX *mem_ctx = talloc_stackframe(); - if (!(mem_ctx = talloc_init("reg_createkey"))) return WERR_NOMEM; - - if (!(name = talloc_strdup(mem_ctx, path))) { + name = talloc_strdup(mem_ctx, path); + if (name == NULL) { err = WERR_NOMEM; - goto error; + goto done; } /* check if the key has subkeys */ err = reg_openkey(mem_ctx, parent, name, REG_KEY_READ, &key); - if (!W_ERROR_IS_OK(err)) { - goto error; - } - if (!W_ERROR_IS_OK(err = fill_subkey_cache(key))) { - goto error; - } + W_ERROR_NOT_OK_GOTO_DONE(err); + + err = fill_subkey_cache(key); + W_ERROR_NOT_OK_GOTO_DONE(err); + if (regsubkey_ctr_numkeys(key->subkeys) > 0) { err = WERR_ACCESS_DENIED; - goto error; + goto done; } /* no subkeys - proceed with delete */ - if ((end = strrchr(name, '\\')) != NULL) { + end = strrchr(name, '\\'); + if (end != NULL) { *end = '\0'; err = reg_openkey(mem_ctx, parent, name, SEC_RIGHTS_CREATE_SUBKEY, &tmp_key); - if (!W_ERROR_IS_OK(err)) { - goto error; - } + W_ERROR_NOT_OK_GOTO_DONE(err); parent = tmp_key; name = end+1; @@ -584,29 +581,26 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path) if (name[0] == '\0') { err = WERR_INVALID_PARAM; - goto error; + goto done; } - if (!W_ERROR_IS_OK(err = fill_subkey_cache(parent))) { - goto error; - } + err = fill_subkey_cache(parent); + W_ERROR_NOT_OK_GOTO_DONE(err); err = regsubkey_ctr_delkey(parent->subkeys, name); - if (!W_ERROR_IS_OK(err)) { - goto error; - } + W_ERROR_NOT_OK_GOTO_DONE(err); if (!store_reg_keys(parent->key, parent->subkeys)) { TALLOC_FREE(parent->subkeys); err = WERR_REG_IO_FAILURE; - goto error; + goto done; } regkey_set_secdesc(key->key, NULL); err = WERR_OK; - error: +done: TALLOC_FREE(mem_ctx); return err; } |