[PATCH] extended RPC-WINREG test [Re: svn commit: samba r23578]
Michael Adam
ma at sernet.de
Thu Jun 21 22:28:42 GMT 2007
Hi,
I have changed samba3 behaviour of reg_deletekey to behave like
windows in that ACCESS_DENIED is returned when trying to delete
a key that has subkeys.
I have also extended s4:torture/rpc/winreg.c to test to check
for this behaviour. Attached find the patch for review.
Furthermore I found the following problems with the winreg test:
* it runs ok agains w2k3, but "smbtorture test" keys don't
get deleted at the end.
* it fails against w2k (panic)
* it fails to create keys for s3, has lots of NT_STATUS_NET_WRITE_FAULT
and eventually ends with "ERROR IN TEST WINREG! - Unknown error/failure"
I did not debug this much further due to lack of time mostly.
(I called "smbtorture -Uuser%pass ncacn_np:ip-address RPC-WINREG")
Cheers, Michael
On Do, Jun 21, 2007 at 10:18:42 +0000, obnox at samba.org wrote:
> Author: obnox
> Date: 2007-06-21 22:18:42 +0000 (Thu, 21 Jun 2007)
> New Revision: 23578
>
> WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23578
>
> Log:
> 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
>
>
> Modified:
> branches/SAMBA_3_0/source/registry/reg_api.c
> branches/SAMBA_3_0_26/source/registry/reg_api.c
>
>
> Changeset:
> Modified: branches/SAMBA_3_0/source/registry/reg_api.c
> ===================================================================
> --- branches/SAMBA_3_0/source/registry/reg_api.c 2007-06-21 22:10:41 UTC (rev 23577)
> +++ branches/SAMBA_3_0/source/registry/reg_api.c 2007-06-21 22:18:42 UTC (rev 23578)
> @@ -386,6 +386,7 @@
> 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 @@
> goto error;
> }
>
> + /* 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) {
> - struct registry_key *tmp;
> -
> *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;
> }
>
>
> Modified: branches/SAMBA_3_0_26/source/registry/reg_api.c
> ===================================================================
> --- branches/SAMBA_3_0_26/source/registry/reg_api.c 2007-06-21 22:10:41 UTC (rev 23577)
> +++ branches/SAMBA_3_0_26/source/registry/reg_api.c 2007-06-21 22:18:42 UTC (rev 23578)
> @@ -386,6 +386,7 @@
> 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 @@
> goto error;
> }
>
> + /* 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) {
> - struct registry_key *tmp;
> -
> *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;
> }
>
>
--
i.A. Michael Adam
--
Michael Adam <ma at sernet.de>
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.SerNet.DE, mailto: Info @ SerNet.DE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff
Type: text/x-patch
Size: 2874 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20070622/9c7af5eb/diff.bin
More information about the samba-technical
mailing list