svn commit: samba r23578 - in branches: SAMBA_3_0/source/registry SAMBA_3_0_26/source/registry

obnox at samba.org obnox at samba.org
Thu Jun 21 22:18:42 GMT 2007


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;
 	}
 



More information about the samba-cvs mailing list