[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Fri May 21 08:00:07 MDT 2010


The branch, master has been updated
       via  b6b3822... s4-torture: Improved the winreg symlink test.
       via  74d0fc1... s4-torture: Disable the security descriptor tests.
       via  225bd02... s4-torture: Try to fix the winreg tests.
      from  5fe476b... s4:ldb: add --controls support to ldbedit

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b6b38222894014de029131eb5b6d573294af314e
Author: Andreas Schneider <asn at samba.org>
Date:   Thu May 20 14:00:57 2010 +0200

    s4-torture: Improved the winreg symlink test.
    
    This test is still disabled as we don't know how to remove a symbolic
    link. It looks like there only DeleteKey functions which can work on a
    handle are able to delete a symbolic link.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>

commit 74d0fc10fd646e493a98a00e524f17e9c4f3df3f
Author: Andreas Schneider <asn at samba.org>
Date:   Fri May 21 12:49:23 2010 +0200

    s4-torture: Disable the security descriptor tests.

commit 225bd02dab1a0656461d3d5e30ad03034e8c64f1
Author: Andreas Schneider <asn at samba.org>
Date:   Fri May 21 12:42:55 2010 +0200

    s4-torture: Try to fix the winreg tests.

-----------------------------------------------------------------------

Summary of changes:
 source4/torture/rpc/winreg.c |  219 +++++++++++++++++++++++++++++++----------
 1 files changed, 165 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index 370bd67..67afce2 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -28,18 +28,19 @@
 #include "param/param.h"
 #include "lib/registry/registry.h"
 
-#define TEST_KEY_BASE "smbtorture test"
-#define TEST_KEY1 TEST_KEY_BASE "\\spottyfoot"
-#define TEST_KEY2 TEST_KEY_BASE "\\with a SD (#1)"
-#define TEST_KEY3 TEST_KEY_BASE "\\with a subkey"
-#define TEST_KEY4 TEST_KEY_BASE "\\sd_tests"
-#define TEST_SUBKEY TEST_KEY3 "\\subkey"
-#define TEST_SUBKEY_SD  TEST_KEY4 "\\subkey_sd"
-#define TEST_SUBSUBKEY_SD TEST_KEY4 "\\subkey_sd\\subsubkey_sd"
+#define TEST_KEY_BASE "winreg_torture_test"
+#define TEST_KEY1 "spottyfoot"
+#define TEST_KEY2 "with a SD (#1)"
+#define TEST_KEY3 "with a subkey"
+#define TEST_KEY4 "sd_tests"
+#define TEST_SUBKEY "subkey"
+#define TEST_SUBKEY_SD  "subkey_sd"
+#define TEST_SUBSUBKEY_SD "subkey_sd\\subsubkey_sd"
 #define TEST_VALUE "torture_value_name"
 #define TEST_KEY_VOLATILE "torture_volatile_key"
 #define TEST_SUBKEY_VOLATILE "torture_volatile_subkey"
 #define TEST_KEY_SYMLINK "torture_symlink_key"
+#define TEST_KEY_SYMLINK_DEST "torture_symlink_dest"
 
 #define TEST_SID "S-1-5-21-1234567890-1234567890-1234567890-500"
 
@@ -832,6 +833,8 @@ static bool test_SecurityDescriptorInheritance(struct dcerpc_pipe *p,
 	struct policy_handle new_handle;
 	bool ret = true;
 	struct dcerpc_binding_handle *b = p->binding_handle;
+	const char *test_subkey_sd;
+	const char *test_subsubkey_sd;
 
 	torture_comment(tctx, "SecurityDescriptor inheritance\n");
 
@@ -874,12 +877,14 @@ static bool test_SecurityDescriptorInheritance(struct dcerpc_pipe *p,
 		return false;
 	}
 
-	if (!test_CreateKey(b, tctx, handle, TEST_SUBKEY_SD, NULL)) {
+	test_subkey_sd = talloc_asprintf(tctx, "%s\\%s", key, TEST_SUBKEY_SD);
+
+	if (!test_CreateKey(b, tctx, handle, test_subkey_sd, NULL)) {
 		ret = false;
 		goto out;
 	}
 
-	if (!test_OpenKey(b, tctx, handle, TEST_SUBKEY_SD, &new_handle)) {
+	if (!test_OpenKey(b, tctx, handle, test_subkey_sd, &new_handle)) {
 		ret = false;
 		goto out;
 	}
@@ -890,13 +895,15 @@ static bool test_SecurityDescriptorInheritance(struct dcerpc_pipe *p,
 		goto out;
 	}
 
+	test_subsubkey_sd = talloc_asprintf(tctx, "%s\\%s", key, TEST_SUBSUBKEY_SD);
+
 	test_CloseKey(b, tctx, &new_handle);
-	if (!test_CreateKey(b, tctx, handle, TEST_SUBSUBKEY_SD, NULL)) {
+	if (!test_CreateKey(b, tctx, handle, test_subsubkey_sd, NULL)) {
 		ret = false;
 		goto out;
 	}
 
-	if (!test_OpenKey(b, tctx, handle, TEST_SUBSUBKEY_SD, &new_handle)) {
+	if (!test_OpenKey(b, tctx, handle, test_subsubkey_sd, &new_handle)) {
 		ret = false;
 		goto out;
 	}
@@ -909,10 +916,10 @@ static bool test_SecurityDescriptorInheritance(struct dcerpc_pipe *p,
 
  out:
 	test_CloseKey(b, tctx, &new_handle);
-	test_Cleanup(b, tctx, handle, TEST_SUBKEY_SD);
+	test_Cleanup(b, tctx, handle, test_subkey_sd);
 	test_RestoreSecurity(p, tctx, handle, key, sd_orig);
 
-	return true;
+	return ret;
 }
 
 static bool test_SecurityDescriptorBlockInheritance(struct dcerpc_pipe *p,
@@ -941,6 +948,8 @@ static bool test_SecurityDescriptorBlockInheritance(struct dcerpc_pipe *p,
 	bool ret = true;
 	uint8_t ace_flags = 0x0;
 	struct dcerpc_binding_handle *b = p->binding_handle;
+	const char *test_subkey_sd;
+	const char *test_subsubkey_sd;
 
 	torture_comment(tctx, "SecurityDescriptor inheritance block\n");
 
@@ -980,11 +989,14 @@ static bool test_SecurityDescriptorBlockInheritance(struct dcerpc_pipe *p,
 		return false;
 	}
 
-	if (!test_CreateKey(b, tctx, handle, TEST_SUBSUBKEY_SD, NULL)) {
+	test_subkey_sd = talloc_asprintf(tctx, "%s\\%s", key, TEST_SUBKEY_SD);
+	test_subsubkey_sd = talloc_asprintf(tctx, "%s\\%s", key, TEST_SUBSUBKEY_SD);
+
+	if (!test_CreateKey(b, tctx, handle, test_subsubkey_sd, NULL)) {
 		return false;
 	}
 
-	if (!test_OpenKey(b, tctx, handle, TEST_SUBSUBKEY_SD, &new_handle)) {
+	if (!test_OpenKey(b, tctx, handle, test_subsubkey_sd, &new_handle)) {
 		ret = false;
 		goto out;
 	}
@@ -1008,7 +1020,7 @@ static bool test_SecurityDescriptorBlockInheritance(struct dcerpc_pipe *p,
 
 	test_CloseKey(b, tctx, &new_handle);
 
-	if (!test_OpenKey(b, tctx, handle, TEST_SUBKEY_SD, &new_handle)) {
+	if (!test_OpenKey(b, tctx, handle, test_subkey_sd, &new_handle)) {
 		ret = false;
 		goto out;
 	}
@@ -1028,7 +1040,7 @@ static bool test_SecurityDescriptorBlockInheritance(struct dcerpc_pipe *p,
 
  out:
 	test_CloseKey(b, tctx, &new_handle);
-	test_Cleanup(b, tctx, handle, TEST_SUBKEY_SD);
+	test_Cleanup(b, tctx, handle, test_subkey_sd);
 	test_RestoreSecurity(p, tctx, handle, key, sd_orig);
 
 	return ret;
@@ -2285,23 +2297,55 @@ static const char *kernel_mode_registry_path(struct torture_context *tctx,
 static bool test_symlink_keys(struct torture_context *tctx,
 			      struct dcerpc_binding_handle *b,
 			      struct policy_handle *handle,
+			      const char *key,
 			      int hkey)
 {
 	struct policy_handle new_handle;
 	enum winreg_CreateAction action_taken;
 	DATA_BLOB blob;
-	/* symlink destination needs to be a kernel mode registry path */
-	const char *dest = "\\Registry\\MACHINE\\SOFTWARE\\foo";
+	uint32_t value = 42;
+	const char *test_key_symlink_dest;
+	const char *test_key_symlink;
+	const char *kernel_mode_path;
 
-	/* disable until we know how to *not* screw up a windows registry */
+	/* disable until we know how to delete a symbolic link */
 	torture_skip(tctx, "symlink test disabled");
 
 	torture_comment(tctx, "Testing REG_OPTION_CREATE_LINK key\n");
 
-	test_DeleteKey(b, tctx, handle, TEST_KEY_SYMLINK);
+	/* create destination key with testvalue */
+	test_key_symlink = talloc_asprintf(tctx, "%s\\%s",
+			key, TEST_KEY_SYMLINK);
+	test_key_symlink_dest = talloc_asprintf(tctx, "%s\\%s",
+			key, TEST_KEY_SYMLINK_DEST);
+
+	test_DeleteKey(b, tctx, handle, test_key_symlink);
+
+	torture_assert(tctx,
+		test_CreateKey_opts(tctx, b, handle, test_key_symlink_dest, NULL,
+				    0,
+				    SEC_FLAG_MAXIMUM_ALLOWED,
+				    NULL,
+				    WERR_OK,
+				    &action_taken,
+				    &new_handle),
+		"failed to create symlink destination");
+
+	blob = data_blob_talloc_zero(tctx, 4);
+	SIVAL(blob.data, 0, value);
 
 	torture_assert(tctx,
-		test_CreateKey_opts(tctx, b, handle, TEST_KEY_SYMLINK, NULL,
+		test_SetValue(b, tctx, &new_handle, "TestValue", REG_DWORD, blob.data, blob.length),
+		"failed to create TestValue");
+
+	torture_assert(tctx,
+		test_CloseKey(b, tctx, &new_handle),
+		"failed to close");
+
+	/* create symlink */
+
+	torture_assert(tctx,
+		test_CreateKey_opts(tctx, b, handle, test_key_symlink, NULL,
 				    REG_OPTION_CREATE_LINK | REG_OPTION_VOLATILE,
 				    SEC_FLAG_MAXIMUM_ALLOWED,
 				    NULL,
@@ -2312,9 +2356,12 @@ static bool test_symlink_keys(struct torture_context *tctx,
 
 	torture_assert_int_equal(tctx, action_taken, REG_CREATED_NEW_KEY, "unexpected action");
 
+	kernel_mode_path = kernel_mode_registry_path(tctx, hkey, NULL, test_key_symlink_dest);
+
 	torture_assert(tctx,
 		convert_string_talloc(tctx, CH_UNIX, CH_UTF16,
-				      dest, strlen(dest), /* not NULL terminated */
+				      kernel_mode_path,
+				      strlen(kernel_mode_path), /* not NULL terminated */
 				      &blob.data, &blob.length,
 				      false),
 		"failed to convert");
@@ -2327,8 +2374,28 @@ static bool test_symlink_keys(struct torture_context *tctx,
 		test_CloseKey(b, tctx, &new_handle),
 		"failed to close");
 
+	/* test follow symlink */
+
 	torture_assert(tctx,
-		test_OpenKey_opts(tctx, b, handle, TEST_KEY_SYMLINK,
+		test_OpenKey_opts(tctx, b, handle, test_key_symlink,
+				  0,
+				  SEC_FLAG_MAXIMUM_ALLOWED,
+				  &new_handle,
+				  WERR_OK),
+		"failed to follow symlink key");
+
+	torture_assert(tctx,
+		test_QueryValue(b, tctx, &new_handle, "TestValue"),
+		"failed to query value");
+
+	torture_assert(tctx,
+		test_CloseKey(b, tctx, &new_handle),
+		"failed to close");
+
+	/* delete link */
+
+	torture_assert(tctx,
+		test_OpenKey_opts(tctx, b, handle, test_key_symlink,
 				  REG_OPTION_OPEN_LINK | REG_OPTION_VOLATILE,
 				  SEC_FLAG_MAXIMUM_ALLOWED,
 				  &new_handle,
@@ -2336,7 +2403,21 @@ static bool test_symlink_keys(struct torture_context *tctx,
 		"failed to open symlink key");
 
 	torture_assert(tctx,
-		test_DeleteKey(b, tctx, handle, TEST_KEY_SYMLINK),
+		test_DeleteValue(b, tctx, &new_handle, "SymbolicLinkValue"),
+		"failed to delete value SymbolicLinkValue");
+
+	torture_assert(tctx,
+		test_CloseKey(b, tctx, &new_handle),
+		"failed to close");
+
+	torture_assert(tctx,
+		test_DeleteKey(b, tctx, handle, test_key_symlink),
+		"failed to delete key");
+
+	/* delete destination */
+
+	torture_assert(tctx,
+		test_DeleteKey(b, tctx, handle, test_key_symlink_dest),
 		"failed to delete key");
 
 	return true;
@@ -2345,6 +2426,7 @@ static bool test_symlink_keys(struct torture_context *tctx,
 static bool test_CreateKey_keytypes(struct torture_context *tctx,
 				    struct dcerpc_binding_handle *b,
 				    struct policy_handle *handle,
+				    const char *key,
 				    int hkey)
 {
 
@@ -2358,7 +2440,7 @@ static bool test_CreateKey_keytypes(struct torture_context *tctx,
 		"failed to test volatile keys");
 
 	torture_assert(tctx,
-		test_symlink_keys(tctx, b, handle, hkey),
+		test_symlink_keys(tctx, b, handle, key, hkey),
 		"failed to test symlink keys");
 
 	return true;
@@ -2367,20 +2449,26 @@ static bool test_CreateKey_keytypes(struct torture_context *tctx,
 static bool test_key_base(struct torture_context *tctx,
 			  struct dcerpc_binding_handle *b,
 			  struct policy_handle *handle,
+			  const char *base_key,
 			  int hkey)
 {
 	struct policy_handle newhandle;
 	bool ret = true, created = false, deleted = false;
 	bool created3 = false;
+	const char *test_key1;
+	const char *test_key3;
+	const char *test_subkey;
 
-	test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+	test_Cleanup(b, tctx, handle, base_key);
 
-	if (!test_CreateKey(b, tctx, handle, TEST_KEY_BASE, NULL)) {
+	if (!test_CreateKey(b, tctx, handle, base_key, NULL)) {
 		torture_comment(tctx,
-				"CreateKey (TEST_KEY_BASE) failed\n");
+				"CreateKey(%s) failed\n", base_key);
 	}
 
-	if (!test_CreateKey(b, tctx, handle, TEST_KEY1, NULL)) {
+	test_key1 = talloc_asprintf(tctx, "%s\\%s", base_key, TEST_KEY1);
+
+	if (!test_CreateKey(b, tctx, handle, test_key1, NULL)) {
 		torture_comment(tctx,
 				"CreateKey failed - not considering a failure\n");
 	} else {
@@ -2393,7 +2481,7 @@ static bool test_key_base(struct torture_context *tctx,
 			ret = false;
 		}
 
-		if (!test_OpenKey(b, tctx, handle, TEST_KEY1, &newhandle)) {
+		if (!test_OpenKey(b, tctx, handle, test_key1, &newhandle)) {
 			torture_fail(tctx,
 				     "CreateKey failed (OpenKey after Create didn't work)\n");
 		}
@@ -2403,7 +2491,8 @@ static bool test_key_base(struct torture_context *tctx,
 				"simple SetValue test failed");
 			torture_assert(tctx, test_SetValue_extended(b, tctx, &newhandle),
 				"extended SetValue test failed");
-			torture_assert(tctx, test_CreateKey_keytypes(tctx, b, &newhandle, hkey),
+		} else {
+			torture_assert(tctx, test_CreateKey_keytypes(tctx, b, &newhandle, test_key1, hkey),
 				"keytype test failed");
 		}
 
@@ -2412,7 +2501,7 @@ static bool test_key_base(struct torture_context *tctx,
 				     "CreateKey failed (CloseKey after Open didn't work)\n");
 		}
 
-		if (!test_DeleteKey(b, tctx, handle, TEST_KEY1)) {
+		if (!test_DeleteKey(b, tctx, handle, test_key1)) {
 			torture_comment(tctx, "DeleteKey failed\n");
 			ret = false;
 		} else {
@@ -2425,7 +2514,7 @@ static bool test_key_base(struct torture_context *tctx,
 		}
 
 		if (deleted) {
-			if (!test_OpenKey_opts(tctx, b, handle, TEST_KEY1,
+			if (!test_OpenKey_opts(tctx, b, handle, test_key1,
 					       REG_OPTION_NON_VOLATILE,
 					       SEC_FLAG_MAXIMUM_ALLOWED,
 					       &newhandle,
@@ -2437,51 +2526,62 @@ static bool test_key_base(struct torture_context *tctx,
 			}
 		}
 
-		if (test_CreateKey(b, tctx, handle, TEST_KEY3, NULL)) {
+		test_key3 = talloc_asprintf(tctx, "%s\\%s", base_key, TEST_KEY3);
+
+		if (test_CreateKey(b, tctx, handle, test_key3, NULL)) {
 			created3 = true;
 		}
 
+		test_subkey = talloc_asprintf(tctx, "%s\\%s", test_key3, TEST_SUBKEY);
+
 		if (created3) {
-			if (test_CreateKey(b, tctx, handle, TEST_SUBKEY, NULL)) {
-				if (!test_DeleteKey(b, tctx, handle, TEST_SUBKEY)) {
+			if (test_CreateKey(b, tctx, handle, test_subkey, NULL)) {
+				if (!test_DeleteKey(b, tctx, handle, test_subkey)) {
 					torture_comment(tctx, "DeleteKey failed\n");
 					ret = false;
 				}
 			}
 
-			if (!test_DeleteKey(b, tctx, handle, TEST_KEY3)) {
+			if (!test_DeleteKey(b, tctx, handle, test_key3)) {
 				torture_comment(tctx, "DeleteKey failed\n");
 				ret = false;
 			}
 		}
 	}
 
-	test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+	test_Cleanup(b, tctx, handle, base_key);
 
 	return ret;
 }
 
 static bool test_key_base_sd(struct torture_context *tctx,
 			     struct dcerpc_pipe *p,
-			     struct policy_handle *handle)
+			     struct policy_handle *handle,
+			     const char *base_key)
 {
 	struct policy_handle newhandle;
 	bool ret = true, created2 = false, created4 = false;
 	struct dcerpc_binding_handle *b = p->binding_handle;
+	const char *test_key2;
+	const char *test_key4;
+
+	torture_skip(tctx, "security descriptor test disabled\n");
 
 	if (torture_setting_bool(tctx, "samba3", false) ||
 	    torture_setting_bool(tctx, "samba4", false)) {
 		torture_skip(tctx, "skipping security descriptor tests against Samba");
 	}
 
-	test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+	test_Cleanup(b, tctx, handle, base_key);
 
-	if (!test_CreateKey(b, tctx, handle, TEST_KEY_BASE, NULL)) {
+	if (!test_CreateKey(b, tctx, handle, base_key, NULL)) {
 		torture_comment(tctx,
-				"CreateKey (TEST_KEY_BASE) failed\n");
+				"CreateKey(%s) failed\n", base_key);
 	}
 
-	if (test_CreateKey_sd(b, tctx, handle, TEST_KEY2,
+	test_key2 = talloc_asprintf(tctx, "%s\\%s", base_key, TEST_KEY2);
+
+	if (test_CreateKey_sd(b, tctx, handle, test_key2,
 			      NULL, &newhandle)) {
 		created2 = true;
 	}
@@ -2491,7 +2591,9 @@ static bool test_key_base_sd(struct torture_context *tctx,
 		ret = false;
 	}
 
-	if (test_CreateKey_sd(b, tctx, handle, TEST_KEY4, NULL, &newhandle)) {
+	test_key4 = talloc_asprintf(tctx, "%s\\%s", base_key, TEST_KEY4);
+
+	if (test_CreateKey_sd(b, tctx, handle, test_key4, NULL, &newhandle)) {
 		created4 = true;
 	}
 
@@ -2500,21 +2602,21 @@ static bool test_key_base_sd(struct torture_context *tctx,
 		ret = false;
 	}
 
-	if (created4 && !test_SecurityDescriptors(p, tctx, handle, TEST_KEY4)) {
+	if (created4 && !test_SecurityDescriptors(p, tctx, handle, test_key4)) {
 		ret = false;
 	}
 
-	if (created4 && !test_DeleteKey(b, tctx, handle, TEST_KEY4)) {
+	if (created4 && !test_DeleteKey(b, tctx, handle, test_key4)) {
 		torture_comment(tctx, "DeleteKey failed\n");
 		ret = false;
 	}
 
-	if (created2 && !test_DeleteKey(b, tctx, handle, TEST_KEY2)) {
+	if (created2 && !test_DeleteKey(b, tctx, handle, test_key4)) {
 		torture_comment(tctx, "DeleteKey failed\n");
 		ret = false;
 	}
 
-	test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+	test_Cleanup(b, tctx, handle, base_key);
 
 	return ret;
 }
@@ -2526,6 +2628,7 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
 	bool ret = true;
 	struct winreg_OpenHKLM r;
 	struct dcerpc_binding_handle *b = p->binding_handle;
+	const char *torture_base_key;
 	int hkey = 0;
 
 	winreg_open_fn open_fn = (winreg_open_fn)userdata;
@@ -2544,12 +2647,16 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
 
 	if (open_fn == (winreg_open_fn)dcerpc_winreg_OpenHKLM_r) {
 		hkey = HKEY_LOCAL_MACHINE;
+		torture_base_key = "SOFTWARE\\Samba\\" TEST_KEY_BASE;
 	} else if (open_fn == (winreg_open_fn)dcerpc_winreg_OpenHKU_r) {
 		hkey = HKEY_USERS;
+		torture_base_key = TEST_KEY_BASE;
 	} else if (open_fn == (winreg_open_fn)dcerpc_winreg_OpenHKCR_r) {
 		hkey = HKEY_CLASSES_ROOT;
+		torture_base_key = TEST_KEY_BASE;
 	} else if (open_fn == (winreg_open_fn)dcerpc_winreg_OpenHKCU_r) {
 		hkey = HKEY_CURRENT_USER;
+		torture_base_key = TEST_KEY_BASE;
 	} else {
 		torture_fail(tctx, "unsupported hkey");
 	}
@@ -2560,13 +2667,15 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
 			"failed to test HKLM wellknown keys");
 	}
 
-	if (!test_key_base(tctx, b, &handle, hkey)) {
-		torture_warning(tctx, "failed to test TEST_KEY_BASE");
+	if (!test_key_base(tctx, b, &handle, torture_base_key, hkey)) {
+		torture_warning(tctx, "failed to test TEST_KEY_BASE(%s)",
+				torture_base_key);
 		ret = false;
 	}
 
-	if (!test_key_base_sd(tctx, p, &handle)) {
-		torture_warning(tctx, "failed to test TEST_KEY_BASE sd");
+	if (!test_key_base_sd(tctx, p, &handle, torture_base_key)) {
+		torture_warning(tctx, "failed to test TEST_KEY_BASE(%s) sd",
+				torture_base_key);
 		ret = false;
 	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list