[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Thu Mar 11 11:06:44 MST 2010
The branch, master has been updated
via 09ea04a... s4-smbtorture: add extended SetValue test to RPC-WINREG.
via 3a8d85d... s4-smbtorture: more work on test_key_value() RPC-WINREG test.
from b789814... s3: Make init_smb_request return bool
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 09ea04a7f8edc407761450d30fe9a54cac0d7133
Author: Günther Deschner <gd at samba.org>
Date: Thu Mar 11 18:52:38 2010 +0100
s4-smbtorture: add extended SetValue test to RPC-WINREG.
Really looks like a blob based database frontend.
As it seems, we can set *any* type of data with *any* content on Windows and get
the exact same data back.
Guenther
commit 3a8d85da688bc681e8d80ecde75ea318615fe659
Author: Günther Deschner <gd at samba.org>
Date: Thu Mar 11 18:37:02 2010 +0100
s4-smbtorture: more work on test_key_value() RPC-WINREG test.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source4/torture/rpc/spoolss.c | 16 ++--
source4/torture/rpc/winreg.c | 167 +++++++++++++++++++++++++++++++++++++----
2 files changed, 159 insertions(+), 24 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index c66ca84..d5dfee9 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -3340,14 +3340,14 @@ static bool test_winreg_CloseKey(struct torture_context *tctx,
return true;
}
-static bool test_winreg_QueryValue(struct torture_context *tctx,
- struct dcerpc_pipe *p,
- struct policy_handle *handle,
- const char *value_name,
- enum winreg_Type *type_p,
- uint32_t *data_size_p,
- uint32_t *data_length_p,
- uint8_t **data_p)
+bool test_winreg_QueryValue(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle,
+ const char *value_name,
+ enum winreg_Type *type_p,
+ uint32_t *data_size_p,
+ uint32_t *data_length_p,
+ uint8_t **data_p)
{
struct winreg_QueryValue r;
enum winreg_Type type = REG_NONE;
diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index 9ed0c7b..486826c 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -25,6 +25,8 @@
#include "librpc/gen_ndr/ndr_security.h"
#include "libcli/security/security.h"
#include "torture/rpc/rpc.h"
+#include "param/param.h"
+#include "lib/registry/registry.h"
#define TEST_KEY_BASE "smbtorture test"
#define TEST_KEY1 TEST_KEY_BASE "\\spottyfoot"
@@ -1441,7 +1443,8 @@ static bool test_SetValue(struct dcerpc_pipe *p,
struct winreg_SetValue r;
struct winreg_String name;
- torture_comment(tctx, "Testing SetValue(%s)\n", value_name);
+ torture_comment(tctx, "Testing SetValue(%s), type: %s, offered: 0x%08x)\n",
+ value_name, str_regtype(type), size);
init_winreg_String(&name, value_name);
@@ -1854,23 +1857,84 @@ static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx,
return true;
}
-static bool test_key_value(struct dcerpc_pipe *p,
- struct torture_context *tctx,
- struct policy_handle *handle)
+static bool test_SetValue_simple(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle)
{
const char *value_name = TEST_VALUE;
- enum winreg_Type type = REG_DWORD;
uint32_t value = 0x12345678;
+ const char *string = "torture";
+ DATA_BLOB blob;
+ enum winreg_Type types[] = {
+ REG_DWORD,
+ REG_BINARY,
+ REG_SZ,
+ REG_MULTI_SZ
+ };
+ int t;
+
+ torture_comment(tctx, "Testing SetValue (standard formats)\n");
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+
+ enum winreg_Type w_type;
+ uint32_t w_size, w_length;
+ uint8_t *w_data;
+
+ switch (types[t]) {
+ case REG_DWORD:
+ blob = data_blob_talloc_zero(tctx, 4);
+ SIVAL(blob.data, 0, value);
+ break;
+ case REG_BINARY:
+ blob = data_blob_string_const("binary_blob");
+ break;
+ case REG_SZ:
+ torture_assert(tctx,
+ convert_string_talloc_convenience(tctx, lp_iconv_convenience(tctx->lp_ctx),
+ CH_UNIX, CH_UTF16,
+ string,
+ strlen(string)+1,
+ (void **)&blob.data,
+ &blob.length,
+ false), "");
+ break;
+ case REG_MULTI_SZ:
+ torture_assert(tctx,
+ convert_string_talloc_convenience(tctx, lp_iconv_convenience(tctx->lp_ctx),
+ CH_UNIX, CH_UTF16,
+ string,
+ strlen(string)+1,
+ (void **)&blob.data,
+ &blob.length,
+ false), "");
+ torture_assert(tctx, data_blob_realloc(tctx, &blob, blob.length + 2), "");
+ memset(&blob.data[blob.length - 2], '\0', 2);
+ break;
+ default:
+ break;
+ }
- DATA_BLOB blob = data_blob_talloc_zero(tctx, 4);
- SIVAL(blob.data, 0, value);
+ torture_assert(tctx,
+ test_SetValue(p, tctx, handle, value_name, types[t], blob.data, blob.length),
+ "test_SetValue failed");
+ torture_assert(tctx,
+ test_QueryValue_full(p, tctx, handle, value_name, true),
+ talloc_asprintf(tctx, "test_QueryValue_full for %s value failed", value_name));
+ torture_assert(tctx,
+ test_winreg_QueryValue(tctx, p, handle, value_name, &w_type, &w_size, &w_length, &w_data),
+ "test_winreg_QueryValue failed");
+ torture_assert(tctx,
+ test_DeleteValue(p, tctx, handle, value_name),
+ "test_DeleteValue failed");
- torture_assert(tctx, test_SetValue(p, tctx, handle, value_name, type, blob.data, blob.length),
- "test_SetValue failed");
- torture_assert(tctx, test_QueryValue_full(p, tctx, handle, value_name, true),
- talloc_asprintf(tctx, "test_QueryValue_full for %s value failed", value_name));
- torture_assert(tctx, test_DeleteValue(p, tctx, handle, value_name),
- "test_DeleteValue failed");
+ torture_assert_int_equal(tctx, w_type, types[t], "winreg type mismatch");
+ torture_assert_int_equal(tctx, w_size, blob.length, "winreg size mismatch");
+ torture_assert_int_equal(tctx, w_length, blob.length, "winreg length mismatch");
+ torture_assert_mem_equal(tctx, w_data, blob.data, blob.length, "winreg buffer mismatch");
+ }
+
+ torture_comment(tctx, "Testing SetValue (standard formats) succeeded\n");
return true;
}
@@ -1951,6 +2015,70 @@ static bool test_Open_Security(struct torture_context *tctx,
return ret;
}
+static bool test_SetValue_extended(struct dcerpc_pipe *p,
+ struct torture_context *tctx,
+ struct policy_handle *handle)
+{
+ const char *value_name = TEST_VALUE;
+ enum winreg_Type types[] = {
+ REG_NONE,
+ REG_SZ,
+ REG_EXPAND_SZ,
+ REG_BINARY,
+ REG_DWORD,
+ REG_DWORD_BIG_ENDIAN,
+ REG_LINK,
+ REG_MULTI_SZ,
+ REG_RESOURCE_LIST,
+ REG_FULL_RESOURCE_DESCRIPTOR,
+ REG_RESOURCE_REQUIREMENTS_LIST,
+ REG_QWORD,
+ 12,
+ 13,
+ 14,
+ 55,
+ 123456,
+ 653210
+ };
+ const char *str = "abcdefghijklmnopqrstuvwxzy";
+ int t, s;
+
+ torture_comment(tctx, "Testing SetValue (extended formats)\n");
+
+ for (t=0; t < ARRAY_SIZE(types); t++) {
+ for (s=0; s < strlen(str); s++) {
+
+ enum winreg_Type w_type;
+ uint32_t w_size, w_length;
+ uint8_t *w_data;
+
+ const char *string = talloc_strndup(tctx, str, s);
+ DATA_BLOB blob = data_blob_string_const(string);
+
+ torture_assert(tctx,
+ test_SetValue(p, tctx, handle, value_name, types[t], blob.data, blob.length),
+ "test_SetValue failed");
+
+ torture_assert(tctx,
+ test_winreg_QueryValue(tctx, p, handle, value_name, &w_type, &w_size, &w_length, &w_data),
+ "test_winreg_QueryValue failed");
+
+ torture_assert(tctx,
+ test_DeleteValue(p, tctx, handle, value_name),
+ "test_DeleteValue failed");
+
+ torture_assert_int_equal(tctx, w_type, types[t], "winreg type mismatch");
+ torture_assert_int_equal(tctx, w_size, blob.length, "winreg size mismatch");
+ torture_assert_int_equal(tctx, w_length, blob.length, "winreg length mismatch");
+ torture_assert_mem_equal(tctx, w_data, blob.data, blob.length, "winreg buffer mismatch");
+ }
+ }
+
+ torture_comment(tctx, "Testing SetValue (extended formats) succeeded\n");
+
+ return true;
+}
+
#define KEY_CURRENT_VERSION "SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION"
#define VALUE_CURRENT_VERSION "CurrentVersion"
@@ -2011,9 +2139,16 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p,
torture_fail(tctx,
"CreateKey failed (OpenKey after Create didn't work)\n");
- if (created && !test_key_value(p, tctx, &newhandle)) {
- torture_fail(tctx,
- "test_key_value failed\n");
+ if (created) {
+ torture_assert(tctx, test_SetValue_simple(p, tctx, &newhandle),
+ "simple SetValue test failed");
+ if (!test_SetValue_extended(p, tctx, &newhandle)) {
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ torture_warning(tctx, "extended SetValue test failed");
+ } else {
+ torture_fail(tctx, "extended SetValue test failed");
+ }
+ }
}
if (created && !test_CloseKey(p, tctx, &newhandle))
--
Samba Shared Repository
More information about the samba-cvs
mailing list