summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-03-17 01:25:42 +0100
committerGünther Deschner <gd@samba.org>2010-03-17 11:48:52 +0100
commit3db9729240dedd74cdf3d404b68ac45ef0fe0bca (patch)
tree31557973f6b4bc2f5c0ae6eedaba2d020e40db91 /source4
parent75a4dffac1e25293e67fc1b471fb8d74c2f40e61 (diff)
downloadsamba-3db9729240dedd74cdf3d404b68ac45ef0fe0bca.tar.gz
samba-3db9729240dedd74cdf3d404b68ac45ef0fe0bca.tar.bz2
samba-3db9729240dedd74cdf3d404b68ac45ef0fe0bca.zip
s4-smbtorture: re-arrange tests in RPC-WINREG.
Mostly choping test_Open() into smaller parts. Guenther
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/rpc/winreg.c300
1 files changed, 145 insertions, 155 deletions
diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index f866115a44..2a26bcac52 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -67,6 +67,8 @@ static bool test_GetVersion(struct dcerpc_binding_handle *b,
struct winreg_GetVersion r;
uint32_t v;
+ torture_comment(tctx, "Testing GetVersion\n");
+
ZERO_STRUCT(r);
r.in.handle = handle;
r.out.version = &v;
@@ -1995,81 +1997,6 @@ static bool test_SetValue_simple(struct dcerpc_binding_handle *b,
typedef NTSTATUS (*winreg_open_fn)(struct dcerpc_binding_handle *, TALLOC_CTX *, void *);
-static bool test_Open_Security(struct torture_context *tctx,
- struct dcerpc_pipe *p, void *userdata)
-{
- struct policy_handle handle, newhandle;
- bool ret = true, created2 = false;
- bool created4 = false;
- struct winreg_OpenHKLM r;
- struct dcerpc_binding_handle *b = p->binding_handle;
-
- winreg_open_fn open_fn = userdata;
-
- ZERO_STRUCT(r);
- r.in.system_name = 0;
- r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r.out.handle = &handle;
-
- torture_assert_ntstatus_ok(tctx, open_fn(b, tctx, &r),
- "open");
-
- test_Cleanup(b, tctx, &handle, TEST_KEY_BASE);
-
- if (!test_CreateKey(b, tctx, &handle, TEST_KEY_BASE, NULL)) {
- torture_comment(tctx,
- "CreateKey (TEST_KEY_BASE) failed\n");
- }
-
- if (test_CreateKey_sd(b, tctx, &handle, TEST_KEY2,
- NULL, &newhandle)) {
- created2 = true;
- }
-
- if (created2 && !test_CloseKey(b, tctx, &newhandle)) {
- torture_comment(tctx, "CloseKey failed\n");
- ret = false;
- }
-
- if (test_CreateKey_sd(b, tctx, &handle, TEST_KEY4, NULL, &newhandle)) {
- created4 = true;
- }
-
- if (created4 && !test_CloseKey(b, tctx, &newhandle)) {
- torture_comment(tctx, "CloseKey failed\n");
- ret = false;
- }
-
- if (created4 && !test_SecurityDescriptors(p, tctx, &handle, TEST_KEY4)) {
- ret = false;
- }
-
- 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)) {
- torture_comment(tctx, "DeleteKey failed\n");
- ret = false;
- }
-
- /* The HKCR hive has a very large fanout */
- if (open_fn == (void *)dcerpc_winreg_OpenHKCR_r) {
- if(!test_key(p, tctx, &handle, MAX_DEPTH - 1, true)) {
- ret = false;
- }
- } else {
- if (!test_key(p, tctx, &handle, 0, true)) {
- ret = false;
- }
- }
-
- test_Cleanup(b, tctx, &handle, TEST_KEY_BASE);
-
- return ret;
-}
-
static bool test_SetValue_extended(struct dcerpc_binding_handle *b,
struct torture_context *tctx,
struct policy_handle *handle)
@@ -2330,108 +2257,188 @@ static bool test_CreateKey_keytypes(struct torture_context *tctx,
return true;
}
-static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
- void *userdata)
+static bool test_key_base(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle)
{
- struct policy_handle handle, newhandle;
+ struct policy_handle newhandle;
bool ret = true, created = false, deleted = false;
- bool created3 = false, created_subkey = false;
- struct winreg_OpenHKLM r;
- struct dcerpc_binding_handle *b = p->binding_handle;
+ bool created3 = false;
- winreg_open_fn open_fn = userdata;
-
- ZERO_STRUCT(r);
- r.in.system_name = 0;
- r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- r.out.handle = &handle;
-
- torture_assert_ntstatus_ok(tctx, open_fn(b, tctx, &r),
- "open");
-
- if (open_fn == (void *)dcerpc_winreg_OpenHKLM_r) {
- torture_assert(tctx,
- test_HKLM_wellknown(tctx, b, &handle),
- "failed to test HKLM wellknown keys");
- }
-
- test_Cleanup(b, tctx, &handle, TEST_KEY_BASE);
+ test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
- if (!test_CreateKey(b, tctx, &handle, TEST_KEY_BASE, NULL)) {
+ if (!test_CreateKey(b, tctx, handle, TEST_KEY_BASE, NULL)) {
torture_comment(tctx,
"CreateKey (TEST_KEY_BASE) failed\n");
}
- if (!test_CreateKey(b, tctx, &handle, TEST_KEY1, NULL)) {
+ if (!test_CreateKey(b, tctx, handle, TEST_KEY1, NULL)) {
torture_comment(tctx,
"CreateKey failed - not considering a failure\n");
} else {
created = true;
}
- if (created && !test_FlushKey(b, tctx, &handle)) {
- torture_comment(tctx, "FlushKey failed\n");
- ret = false;
- }
+ if (created) {
+ if (!test_FlushKey(b, tctx, handle)) {
+ torture_comment(tctx, "FlushKey failed\n");
+ ret = false;
+ }
- if (created && !test_OpenKey(b, tctx, &handle, TEST_KEY1, &newhandle))
- torture_fail(tctx,
- "CreateKey failed (OpenKey after Create didn't work)\n");
+ if (!test_OpenKey(b, tctx, handle, TEST_KEY1, &newhandle)) {
+ torture_fail(tctx,
+ "CreateKey failed (OpenKey after Create didn't work)\n");
+ }
- if (created) {
torture_assert(tctx, test_SetValue_simple(b, tctx, &newhandle),
"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),
"keytype test failed");
+
+ if (!test_CloseKey(b, tctx, &newhandle)) {
+ torture_fail(tctx,
+ "CreateKey failed (CloseKey after Open didn't work)\n");
+ }
+
+ if (!test_DeleteKey(b, tctx, handle, TEST_KEY1)) {
+ torture_comment(tctx, "DeleteKey failed\n");
+ ret = false;
+ } else {
+ deleted = true;
+ }
+
+ if (!test_FlushKey(b, tctx, handle)) {
+ torture_comment(tctx, "FlushKey failed\n");
+ ret = false;
+ }
+
+ if (deleted) {
+ if (!test_OpenKey_opts(tctx, b, handle, TEST_KEY1,
+ REG_KEYTYPE_NON_VOLATILE,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &newhandle,
+ WERR_BADFILE)) {
+ torture_comment(tctx,
+ "DeleteKey failed (OpenKey after Delete "
+ "did not return WERR_BADFILE)\n");
+ ret = false;
+ }
+ }
+
+ if (test_CreateKey(b, tctx, handle, TEST_KEY3, NULL)) {
+ created3 = true;
+ }
+
+ if (created3) {
+ 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)) {
+ torture_comment(tctx, "DeleteKey failed\n");
+ ret = false;
+ }
+ }
}
- if (created && !test_CloseKey(b, tctx, &newhandle))
- torture_fail(tctx,
- "CreateKey failed (CloseKey after Open didn't work)\n");
+ test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
- if (created && !test_DeleteKey(b, tctx, &handle, TEST_KEY1)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ return ret;
+}
+
+static bool test_key_base_sd(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
+{
+ struct policy_handle newhandle;
+ bool ret = true, created2 = false, created4 = false;
+ struct dcerpc_binding_handle *b = p->binding_handle;
+
+ test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+
+ if (!test_CreateKey(b, tctx, handle, TEST_KEY_BASE, NULL)) {
+ torture_comment(tctx,
+ "CreateKey (TEST_KEY_BASE) failed\n");
+ }
+
+ if (test_CreateKey_sd(b, tctx, handle, TEST_KEY2,
+ NULL, &newhandle)) {
+ created2 = true;
+ }
+
+ if (created2 && !test_CloseKey(b, tctx, &newhandle)) {
+ torture_comment(tctx, "CloseKey failed\n");
ret = false;
- } else {
- deleted = true;
}
- if (created && !test_FlushKey(b, tctx, &handle)) {
- torture_comment(tctx, "FlushKey failed\n");
+ if (test_CreateKey_sd(b, tctx, handle, TEST_KEY4, NULL, &newhandle)) {
+ created4 = true;
+ }
+
+ if (created4 && !test_CloseKey(b, tctx, &newhandle)) {
+ torture_comment(tctx, "CloseKey failed\n");
ret = false;
}
- if (created && deleted &&
- !test_OpenKey_opts(tctx, b, &handle, TEST_KEY1,
- REG_KEYTYPE_NON_VOLATILE,
- SEC_FLAG_MAXIMUM_ALLOWED,
- &newhandle,
- WERR_BADFILE)) {
- torture_comment(tctx,
- "DeleteKey failed (OpenKey after Delete "
- "did not return WERR_BADFILE)\n");
+ if (created4 && !test_SecurityDescriptors(p, tctx, handle, TEST_KEY4)) {
+ ret = false;
+ }
+
+ 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)) {
+ torture_comment(tctx, "DeleteKey failed\n");
ret = false;
}
+ test_Cleanup(b, tctx, handle, TEST_KEY_BASE);
+
+ return ret;
+}
+
+static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
+ void *userdata)
+{
+ struct policy_handle handle;
+ bool ret = true;
+ struct winreg_OpenHKLM r;
+ struct dcerpc_binding_handle *b = p->binding_handle;
+
+ winreg_open_fn open_fn = userdata;
+
+ r.in.system_name = 0;
+ r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ r.out.handle = &handle;
+
+ torture_assert_ntstatus_ok(tctx, open_fn(b, tctx, &r),
+ "open");
+
if (!test_GetVersion(b, tctx, &handle)) {
torture_comment(tctx, "GetVersion failed\n");
ret = false;
}
- if (created && test_CreateKey(b, tctx, &handle, TEST_KEY3, NULL)) {
- created3 = true;
+ if (open_fn == (void *)dcerpc_winreg_OpenHKLM_r) {
+ torture_assert(tctx,
+ test_HKLM_wellknown(tctx, b, &handle),
+ "failed to test HKLM wellknown keys");
}
- if (created3 &&
- test_CreateKey(b, tctx, &handle, TEST_SUBKEY, NULL)) {
- created_subkey = true;
+ if (!test_key_base(tctx, b, &handle)) {
+ torture_warning(tctx, "failed to test TEST_KEY_BASE");
+ ret = false;
}
- if (created_subkey &&
- !test_DeleteKey(b, tctx, &handle, TEST_KEY3)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ if (!test_key_base_sd(tctx, p, &handle)) {
+ torture_warning(tctx, "failed to test TEST_KEY_BASE sd");
ret = false;
}
@@ -2446,8 +2453,6 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
}
}
- test_Cleanup(b, tctx, &handle, TEST_KEY_BASE);
-
return ret;
}
@@ -2468,33 +2473,18 @@ struct torture_suite *torture_rpc_winreg(TALLOC_CTX *mem_ctx)
test_InitiateSystemShutdownEx);
test->dangerous = true;
- /* Basic tests without security descriptors */
- torture_rpc_tcase_add_test_ex(tcase, "HKLM-basic",
+ torture_rpc_tcase_add_test_ex(tcase, "HKLM",
test_Open,
(winreg_open_fn)dcerpc_winreg_OpenHKLM_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKU-basic",
+ torture_rpc_tcase_add_test_ex(tcase, "HKU",
test_Open,
(winreg_open_fn)dcerpc_winreg_OpenHKU_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKCR-basic",
+ torture_rpc_tcase_add_test_ex(tcase, "HKCR",
test_Open,
(winreg_open_fn)dcerpc_winreg_OpenHKCR_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKCU-basic",
+ torture_rpc_tcase_add_test_ex(tcase, "HKCU",
test_Open,
(winreg_open_fn)dcerpc_winreg_OpenHKCU_r);
- /* Security descriptor tests */
- torture_rpc_tcase_add_test_ex(tcase, "HKLM-security",
- test_Open_Security,
- (winreg_open_fn)dcerpc_winreg_OpenHKLM_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKU-security",
- test_Open_Security,
- (winreg_open_fn)dcerpc_winreg_OpenHKU_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKCR-security",
- test_Open_Security,
- (winreg_open_fn)dcerpc_winreg_OpenHKCR_r);
- torture_rpc_tcase_add_test_ex(tcase, "HKCU-security",
- test_Open_Security,
- (winreg_open_fn)dcerpc_winreg_OpenHKCU_r);
-
return suite;
}