static bool test_QueryInfoKey(struct dcerpc_binding_handle *b,
struct torture_context *tctx,
- struct policy_handle *handle, char *kclass)
+ struct policy_handle *handle,
+ char *kclass,
+ uint32_t *pmax_valnamelen,
+ uint32_t *pmax_valbufsize)
{
struct winreg_QueryInfoKey r;
uint32_t num_subkeys, max_subkeylen, max_classlen,
torture_assert_werr_ok(tctx, r.out.result, "QueryInfoKey failed");
+ if (pmax_valnamelen) {
+ *pmax_valnamelen = max_valnamelen;
+ }
+
+ if (pmax_valbufsize) {
+ *pmax_valbufsize = max_valbufsize;
+ }
+
return true;
}
enum winreg_Type type = 0;
uint32_t size = max_valbufsize, zero = 0;
bool ret = true;
- uint8_t buf8;
+ uint8_t *data = NULL;
struct winreg_ValNameBuf name;
-
- name.name = "";
- name.size = 1024;
+ char n = '\0';
ZERO_STRUCT(r);
r.in.handle = handle;
r.in.name = &name;
r.out.name = &name;
r.in.type = &type;
- r.in.value = &buf8;
r.in.length = &zero;
r.in.size = &size;
do {
+ name.name = &n;
+ name.size = max_valnamelen + 2;
+ name.length = 0;
+
+ data = NULL;
+ if (size) {
+ data = (uint8_t *) talloc_array(tctx, uint8_t *, size);
+ }
+ r.in.value = data;
+
torture_assert_ntstatus_ok(tctx,
dcerpc_winreg_EnumValue_r(b, tctx, &r),
"EnumValue failed");
r.out.name->name);
}
+ talloc_free(data);
+
r.in.enum_index++;
} while (W_ERROR_IS_OK(r.out.result));
bool test_security)
{
struct dcerpc_binding_handle *b = p->binding_handle;
+ uint32_t max_valnamelen = 0;
+ uint32_t max_valbufsize = 0;
if (depth == MAX_DEPTH)
return true;
- if (!test_QueryInfoKey(b, tctx, handle, NULL)) {
+ if (!test_QueryInfoKey(b, tctx, handle, NULL,
+ &max_valnamelen, &max_valbufsize)) {
}
if (!test_NotifyChangeKeyValue(b, tctx, handle)) {
if (!test_EnumKey(p, tctx, handle, depth, test_security)) {
}
- if (!test_EnumValue(b, tctx, handle, 0xFF, 0xFFFF)) {
+ if (!test_EnumValue(b, tctx, handle, max_valnamelen, max_valbufsize)) {
+ }
+
+ if (!test_EnumValue(b, tctx, handle, max_valnamelen, 0xFFFF)) {
}
test_CloseKey(b, tctx, handle);
#define VALUE_CURRENT_VERSION "CurrentVersion"
#define VALUE_SYSTEM_ROOT "SystemRoot"
+static const struct {
+ const char *values[3];
+ uint32_t num_values;
+ bool existing_value;
+ const char *error_message;
+} multiple_values_tests[] = {
+ {
+ .values = { VALUE_CURRENT_VERSION, NULL, NULL },
+ .num_values = 1,
+ .existing_value = true,
+ .error_message = NULL
+ },{
+ .values = { VALUE_SYSTEM_ROOT, NULL, NULL },
+ .num_values = 1,
+ .existing_value = true,
+ .error_message = NULL
+ },{
+ .values = { VALUE_CURRENT_VERSION, VALUE_SYSTEM_ROOT, NULL },
+ .num_values = 2,
+ .existing_value = true,
+ .error_message = NULL
+ },{
+ .values = { VALUE_CURRENT_VERSION, VALUE_SYSTEM_ROOT,
+ VALUE_CURRENT_VERSION },
+ .num_values = 3,
+ .existing_value = true,
+ .error_message = NULL
+ },{
+ .values = { VALUE_CURRENT_VERSION, NULL, VALUE_SYSTEM_ROOT },
+ .num_values = 3,
+ .existing_value = false,
+ .error_message = NULL
+ },{
+ .values = { VALUE_CURRENT_VERSION, "", VALUE_SYSTEM_ROOT },
+ .num_values = 3,
+ .existing_value = false,
+ .error_message = NULL
+ },{
+ .values = { "IDoNotExist", NULL, NULL },
+ .num_values = 1,
+ .existing_value = false,
+ .error_message = NULL
+ },{
+ .values = { "IDoNotExist", VALUE_CURRENT_VERSION, NULL },
+ .num_values = 2,
+ .existing_value = false,
+ .error_message = NULL
+ },{
+ .values = { VALUE_CURRENT_VERSION, "IDoNotExist", NULL },
+ .num_values = 2,
+ .existing_value = false,
+ .error_message = NULL
+ }
+};
+
static bool test_HKLM_wellknown(struct torture_context *tctx,
struct dcerpc_binding_handle *b,
struct policy_handle *handle)
{
struct policy_handle newhandle;
int i;
- static const struct {
- const char *values[3];
- uint32_t num_values;
- bool existing_value;
- const char *error_message;
- } multiple_values_tests[] = {
- {
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = NULL,
- .values[2] = NULL,
- .num_values = 1,
- .existing_value = true
- },{
- .values[0] = VALUE_SYSTEM_ROOT,
- .values[1] = NULL,
- .values[2] = NULL,
- .num_values = 1,
- .existing_value = true
- },{
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = VALUE_SYSTEM_ROOT,
- .values[2] = NULL,
- .num_values = 2,
- .existing_value = true
- },{
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = VALUE_SYSTEM_ROOT,
- .values[2] = VALUE_CURRENT_VERSION,
- .num_values = 3,
- .existing_value = true
- },{
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = NULL,
- .values[2] = VALUE_SYSTEM_ROOT,
- .num_values = 3,
- .existing_value = false
- },{
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = "",
- .values[2] = VALUE_SYSTEM_ROOT,
- .num_values = 3,
- .existing_value = false
- },{
- .values[0] = "IDoNotExist",
- .values[1] = NULL,
- .values[2] = NULL,
- .num_values = 1,
- .existing_value = false
- },{
- .values[0] = "IDoNotExist",
- .values[1] = VALUE_CURRENT_VERSION,
- .values[2] = NULL,
- .num_values = 2,
- .existing_value = false
- },{
- .values[0] = VALUE_CURRENT_VERSION,
- .values[1] = "IDoNotExist",
- .values[2] = NULL,
- .num_values = 2,
- .existing_value = false
- }
- };
/* FIXME: s3 does not support SEC_FLAG_MAXIMUM_ALLOWED yet */
if (torture_setting_bool(tctx, "samba3", false)) {
struct policy_handle *handle,
int hkey)
{
- struct policy_handle new_handle;
+ struct policy_handle new_handle, hive_handle;
enum winreg_CreateAction action_taken;
torture_comment(tctx, "Testing VOLATILE key\n");
"failed to close");
torture_assert(tctx,
- test_CloseKey(b, tctx, handle),
- "failed to close");
-
- torture_assert(tctx,
- test_OpenHive(tctx, b, handle, hkey),
+ test_OpenHive(tctx, b, &hive_handle, hkey),
"failed top open hive");
torture_assert(tctx,
- test_OpenKey_opts(tctx, b, handle, TEST_KEY_VOLATILE,
+ test_OpenKey_opts(tctx, b, &hive_handle, TEST_KEY_VOLATILE,
REG_OPTION_VOLATILE,
SEC_FLAG_MAXIMUM_ALLOWED,
&new_handle,
"failed to open volatile key");
torture_assert(tctx,
- test_OpenKey_opts(tctx, b, handle, TEST_KEY_VOLATILE,
+ test_OpenKey_opts(tctx, b, &hive_handle, TEST_KEY_VOLATILE,
REG_OPTION_NON_VOLATILE,
SEC_FLAG_MAXIMUM_ALLOWED,
&new_handle,
WERR_BADFILE),
"failed to open volatile key");
+ torture_assert(tctx,
+ test_CloseKey(b, tctx, &hive_handle),
+ "failed to close");
+
+ torture_assert(tctx,
+ test_DeleteKey(b, tctx, handle, TEST_KEY_VOLATILE),
+ "failed to delete key");
+
+
torture_comment(tctx, "Testing VOLATILE key succeeded\n");
return true;
}
if (!test_DeleteKey(b, tctx, handle, test_key1)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ torture_comment(tctx, "DeleteKey(%s) failed\n",
+ test_key1);
ret = false;
} else {
deleted = 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");
+ torture_comment(tctx, "DeleteKey(%s) failed\n", test_subkey);
ret = false;
}
}
if (!test_DeleteKey(b, tctx, handle, test_key3)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ torture_comment(tctx, "DeleteKey(%s) failed\n", test_key3);
ret = false;
}
}
}
if (created4 && !test_DeleteKey(b, tctx, handle, test_key4)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ torture_comment(tctx, "DeleteKey(%s) failed\n", test_key4);
ret = false;
}
if (created2 && !test_DeleteKey(b, tctx, handle, test_key4)) {
- torture_comment(tctx, "DeleteKey failed\n");
+ torture_comment(tctx, "DeleteKey(%s) failed\n", test_key4);
ret = false;
}
struct torture_suite *torture_rpc_winreg(TALLOC_CTX *mem_ctx)
{
struct torture_rpc_tcase *tcase;
- struct torture_suite *suite = torture_suite_create(mem_ctx, "WINREG");
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "winreg");
struct torture_test *test;
tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg",