1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

s3:registry: replace call to reg_openkey() in reg_createkey() by accesscheck.

Signed-off-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Michael Adam
2012-04-23 16:44:15 +02:00
committed by Andreas Schneider
parent 7f205bcbf2
commit c333885fa1

View File

@ -558,6 +558,7 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;
char *path, *end; char *path, *end;
WERROR err; WERROR err;
uint32_t access_granted;
mem_ctx = talloc_new(ctx); mem_ctx = talloc_new(ctx);
if (mem_ctx == NULL) { if (mem_ctx == NULL) {
@ -618,14 +619,15 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
} }
/* /*
* We have to make a copy of the current key, as we opened it only * We may (e.g. in the iteration) have opened the key with ENUM_SUBKEY.
* with ENUM_SUBKEY access. * Instead of re-opening the key with CREATE_SUB_KEY, we simply
* duplicate the access check here and skip the expensive full open.
*/ */
if (!regkey_access_check(key->key, KEY_CREATE_SUB_KEY, &access_granted,
err = reg_openkey(mem_ctx, key, "", KEY_CREATE_SUB_KEY, key->token))
&create_parent); {
if (!W_ERROR_IS_OK(err)) { err = WERR_ACCESS_DENIED;
goto trans_done; goto done;
} }
/* /*
@ -641,7 +643,7 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
* Now open the newly created key * Now open the newly created key
*/ */
err = reg_openkey(ctx, create_parent, path, desired_access, pkey); err = reg_openkey(ctx, key, path, desired_access, pkey);
if (W_ERROR_IS_OK(err) && (paction != NULL)) { if (W_ERROR_IS_OK(err) && (paction != NULL)) {
*paction = REG_CREATED_NEW_KEY; *paction = REG_CREATED_NEW_KEY;
} }