summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-06-21 22:18:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:32 -0500
commitf7de0933f3770359b54ea2950be51ad9889d6bbc (patch)
tree0f69cb42f60e5aaeb202aad004cac86dc1a92788 /source3
parentf1d263eb62ca3238d6f6c0abbef03e591121d356 (diff)
downloadsamba-f7de0933f3770359b54ea2950be51ad9889d6bbc.tar.gz
samba-f7de0933f3770359b54ea2950be51ad9889d6bbc.tar.bz2
samba-f7de0933f3770359b54ea2950be51ad9889d6bbc.zip
r23578: When calling DeleteKey for a key that has subkey(s), Windows
returns WERR_ACCESS_DENIED. This adapts reg_deletekey to behave the same way. Michael (This used to be commit 0c9cb69b45e8c51b8c3fa0b0d034a6cad2374055)
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_api.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index 4bcc6d7303..e163759dab 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -386,6 +386,7 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path)
TALLOC_CTX *mem_ctx;
char *name, *end;
int num_subkeys;
+ struct registry_key *tmp_key;
if (!(mem_ctx = talloc_init("reg_createkey"))) return WERR_NOMEM;
@@ -394,18 +395,30 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path)
goto error;
}
- if ((end = strrchr(name, '\\')) != NULL) {
- struct registry_key *tmp;
+ /* check if the key has subkeys */
+ err = reg_openkey(mem_ctx, parent, name, REG_KEY_READ, &tmp_key);
+ if (!W_ERROR_IS_OK(err)) {
+ goto error;
+ }
+ if (!W_ERROR_IS_OK(err = fill_subkey_cache(tmp_key))) {
+ goto error;
+ }
+ if (tmp_key->subkeys->num_subkeys > 0) {
+ err = WERR_ACCESS_DENIED;
+ goto error;
+ }
+ /* no subkeys - proceed with delete */
+ if ((end = strrchr(name, '\\')) != NULL) {
*end = '\0';
err = reg_openkey(mem_ctx, parent, name,
- SEC_RIGHTS_CREATE_SUBKEY, &tmp);
+ SEC_RIGHTS_CREATE_SUBKEY, &tmp_key);
if (!W_ERROR_IS_OK(err)) {
goto error;
}
- parent = tmp;
+ parent = tmp_key;
name = end+1;
}