summaryrefslogtreecommitdiff
path: root/source4/lib/registry/tests
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/registry/tests')
-rw-r--r--source4/lib/registry/tests/bindings.py2
-rw-r--r--source4/lib/registry/tests/diff.c242
-rw-r--r--source4/lib/registry/tests/hive.c94
-rw-r--r--source4/lib/registry/tests/registry.c46
4 files changed, 321 insertions, 63 deletions
diff --git a/source4/lib/registry/tests/bindings.py b/source4/lib/registry/tests/bindings.py
index 314cf778a1..1fb5c70b70 100644
--- a/source4/lib/registry/tests/bindings.py
+++ b/source4/lib/registry/tests/bindings.py
@@ -19,7 +19,7 @@
import os
import unittest
-import registry
+from samba import registry
import samba.tests
class HelperTests(unittest.TestCase):
diff --git a/source4/lib/registry/tests/diff.c b/source4/lib/registry/tests/diff.c
index 690f71fcf7..44ea090527 100644
--- a/source4/lib/registry/tests/diff.c
+++ b/source4/lib/registry/tests/diff.c
@@ -4,6 +4,7 @@
local testing of registry diff functionality
Copyright (C) Jelmer Vernooij 2007
+ Copyright (C) Wilco Baan Hofman 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,28 +24,73 @@
#include "lib/registry/registry.h"
#include "torture/torture.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
-static bool test_generate_diff(struct torture_context *test)
+struct diff_tcase_data {
+ struct registry_context *r1_ctx;
+ struct registry_context *r2_ctx;
+ struct reg_diff_callbacks *callbacks;
+ void *callback_data;
+ char *tempdir;
+ char *filename;
+};
+
+static bool test_generate_diff(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_generate_diff(struct registry_context *ctx1,
- struct registry_context *ctx2,
- const struct reg_diff_callbacks *callbacks,
- void *callback_data)
- */
+ WERROR error;
+ struct diff_tcase_data *td = tcase_data;
+
+ error = reg_generate_diff(td->r1_ctx, td->r2_ctx,
+ td->callbacks,
+ td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_generate_diff");
+
return true;
}
-
-static bool test_diff_load(struct torture_context *test)
+#if 0
+static bool test_diff_load(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_diff_load(const char *filename, const struct reg_diff_callbacks *callbacks, void *callback_data) */
+ struct diff_tcase_data *td = tcase_data;
+ struct smb_iconv_convenience *ic;
+ struct reg_diff_callbacks *callbacks;
+ void *data;
+ WERROR error;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ error = reg_diff_load(td->filename, iconv_convenience, callbacks, data);
+ torture_assert_werr_ok(tctx, error, "reg_diff_load");
return true;
}
-
-static bool test_diff_apply(struct torture_context *test)
+#endif
+static bool test_diff_apply(struct torture_context *tctx, void *tcase_data)
{
- /* _PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx) */
+ struct diff_tcase_data *td = tcase_data;
+ struct registry_key *key;
+ WERROR error;
+
+ error = reg_diff_apply(td->r1_ctx, td->filename);
+ torture_assert_werr_ok(tctx, error, "reg_diff_apply");
+
+ error = td->r1_ctx->ops->get_predefined_key(td->r1_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+
+ /* If this generates an error it could be that the apply doesn't work,
+ * but also that the reg_generate_diff didn't work. */
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Software", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Microsoft", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software\\Microsoft failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Windows", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Microsoft\\Windows failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "CurrentVersion", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Windows\\CurrentVersion failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Policies", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\CurrentVersion\\Policies failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Explorer", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Policies\\Explorer failed");
return true;
}
@@ -58,7 +104,7 @@ static WERROR test_add_key(void *callback_data, const char *key_name)
return WERR_OK;
}
-static bool test_generate_diff_key_add(struct torture_context *test)
+static bool test_generate_diff_key_add(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
struct registry_key rk;
@@ -69,15 +115,15 @@ static bool test_generate_diff_key_add(struct torture_context *test)
cb.add_key = test_add_key;
- if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, test)))
+ if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, tctx)))
return false;
- torture_assert_str_equal(test, added_key, "bla", "key added");
+ torture_assert_str_equal(tctx, added_key, "bla", "key added");
return true;
}
-static bool test_generate_diff_key_null(struct torture_context *test)
+static bool test_generate_diff_key_null(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
@@ -89,18 +135,162 @@ static bool test_generate_diff_key_null(struct torture_context *test)
return true;
}
+static void tcase_add_tests (struct torture_tcase *tcase)
+{
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_add",
+ test_generate_diff_key_add);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_null",
+ test_generate_diff_key_null);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff",
+ test_generate_diff);
+ torture_tcase_add_simple_test(tcase, "test_diff_apply",
+ test_diff_apply);
+/* torture_tcase_add_simple_test(tcase, "test_diff_load",
+ test_diff_load);
+*/
+}
+
+static bool diff_setup_tcase(struct torture_context *tctx, void **data)
+{
+ struct registry_context *r1_ctx, *r2_ctx;
+ WERROR error;
+ NTSTATUS status;
+ struct hive_key *r1_hklm, *r1_hkcu;
+ struct hive_key *r2_hklm, *r2_hkcu;
+ const char *filename;
+ struct diff_tcase_data *td;
+ struct registry_key *key, *newkey;
+ DATA_BLOB blob;
+
+ td = talloc(tctx, struct diff_tcase_data);
+
+ /* Create two registry contexts */
+ error = reg_open_local(tctx, &r1_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 1 for patch tests failed");
+
+ error = reg_open_local(tctx, &r2_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 2 for patch tests failed");
+
+ /* Create temp directory */
+ status = torture_temp_dir(tctx, "patchfile", &td->tempdir);
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 1 */
+ filename = talloc_asprintf(tctx, "%s/r1_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r1_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 2 */
+ filename = talloc_asprintf(tctx, "%s/r2_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r2_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ error = r1_ctx->ops->get_predefined_key(r1_ctx, HKEY_CURRENT_USER, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_CURRENT_USER failed");
+ error = r1_ctx->ops->create_key(r1_ctx, key, "Network", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network failed");
+ error = r1_ctx->ops->create_key(r1_ctx, newkey, "L", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network\\L failed");
+
+ error = r2_ctx->ops->get_predefined_key(r2_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+ error = r2_ctx->ops->create_key(r2_ctx, key, "Software", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Sofware failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Microsoft", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Windows", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft\\Windows failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "CurrentVersion", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Windows\\CurrentVersion failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Policies", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\CurrentVersion\\Policies failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Explorer", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Policies\\Explorer failed");
+
+
+ blob.data = (void *)talloc(r2_ctx, uint32_t);
+ SIVAL(blob.data, 0, 0x03ffffff);
+ blob.length = sizeof(uint32_t);
+
+ r1_ctx->ops->set_value(newkey, "NoDrives", REG_DWORD, blob);
+
+ /* Set test case data */
+ td->r1_ctx = r1_ctx;
+ td->r2_ctx = r2_ctx;
+
+ *data = td;
+
+ return true;
+}
+
+static bool diff_setup_preg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.pol", td->tempdir);
+ error = reg_preg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_preg_diff_save");
+
+ return true;
+}
+
+static bool diff_setup_dotreg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.reg", td->tempdir);
+ error = reg_dotreg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_dotreg_diff_save");
+
+ return true;
+}
+
struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx)
{
+ struct torture_tcase *tcase;
struct torture_suite *suite = torture_suite_create(mem_ctx, "DIFF");
- torture_suite_add_simple_test(suite, "test_generate_diff_key_add",
- test_generate_diff_key_add);
- torture_suite_add_simple_test(suite, "test_generate_diff_key_null",
- test_generate_diff_key_null);
- torture_suite_add_simple_test(suite, "test_diff_apply",
- test_diff_apply);
- torture_suite_add_simple_test(suite, "test_generate_diff",
- test_generate_diff);
- torture_suite_add_simple_test(suite, "test_diff_load",
- test_diff_load);
+
+ tcase = torture_suite_add_tcase(suite, "PReg");
+ torture_tcase_set_fixture(tcase, diff_setup_preg_tcase, NULL);
+ tcase_add_tests(tcase);
+
+ tcase = torture_suite_add_tcase(suite, "dotreg");
+ torture_tcase_set_fixture(tcase, diff_setup_dotreg_tcase, NULL);
+ tcase_add_tests(tcase);
+
return suite;
}
diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c
index 70b0241b04..edc97c2468 100644
--- a/source4/lib/registry/tests/hive.c
+++ b/source4/lib/registry/tests/hive.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/winreg.h"
#include "system/filesys.h"
#include "param/param.h"
+#include "libcli/security/security.h"
static bool test_del_nonexistant_key(struct torture_context *tctx,
const void *test_data)
@@ -68,14 +69,15 @@ static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data)
struct hive_key *root = (struct hive_key *)test_data;
WERROR error;
struct hive_key *subkey;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
error = hive_key_add_name(tctx, root, "Nested Keyll", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(root, "Answer", REG_DWORD,
- data_blob_talloc(tctx, &data, sizeof(data)));
+ data_blob_talloc(tctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
/* This is a new backend. There should be no subkeys and no
@@ -119,7 +121,8 @@ static bool test_del_recursive(struct torture_context *tctx,
struct hive_key *subkey2;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
/* Create a new key under the root */
error = hive_key_add_name(mem_ctx, root, "Parent Key", NULL,
@@ -133,7 +136,7 @@ static bool test_del_recursive(struct torture_context *tctx,
/* Create a new value under "Child Key" */
error = hive_key_set_value(subkey2, "Answer Recursive", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
/* Deleting "Parent Key" will also delete "Child Key" and the value. */
@@ -179,14 +182,15 @@ static bool test_set_value(struct torture_context *tctx,
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
return true;
@@ -198,10 +202,12 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
+ SIVAL(data, 0, 42);
+
error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
@@ -211,7 +217,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
"getting missing value");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value);
@@ -220,7 +226,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
torture_assert_int_equal(tctx, value.length, 4, "value length");
torture_assert_int_equal(tctx, type, REG_DWORD, "value type");
- torture_assert_int_equal(tctx, data, IVAL(value.data, 0),
+ torture_assert_mem_equal(tctx, &data, value.data, sizeof(uint32_t),
"value data");
return true;
@@ -232,16 +238,18 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data)
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
+ SIVAL(data, 0, 42);
+
error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_key_del_value(subkey, "Answer");
@@ -264,17 +272,19 @@ static bool test_list_values(struct torture_context *tctx,
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
const char *name;
+ int data_val = 42;
+ SIVAL(data, 0, data_val);
error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_get_value_by_index(mem_ctx, subkey, 0, &name,
@@ -287,7 +297,7 @@ static bool test_list_values(struct torture_context *tctx,
torture_assert_int_equal(tctx, type, REG_DWORD, "value type");
- torture_assert_int_equal(tctx, data, IVAL(value.data, 0), "value data");
+ torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data");
error = hive_get_value_by_index(mem_ctx, subkey, 1, &name,
&type, &value);
@@ -297,6 +307,56 @@ static bool test_list_values(struct torture_context *tctx,
return true;
}
+static bool test_hive_security(struct torture_context *tctx, const void *_data)
+{
+ struct hive_key *subkey = NULL;
+ const struct hive_key *root = _data;
+ WERROR error;
+ struct security_descriptor *osd, *nsd;
+
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+
+ error = hive_key_add_name(tctx, root, "SecurityKey", NULL,
+ osd, &subkey);
+ torture_assert_werr_ok(tctx, error, "hive_key_add_name");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ /* Create a fresh security descriptor */
+ talloc_free(osd);
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+ error = hive_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ return true;
+}
+
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key",
@@ -324,6 +384,8 @@ static void tcase_add_tests(struct torture_tcase *tcase)
test_del_key);
torture_tcase_add_simple_test_const(tcase, "del_value",
test_del_value);
+ torture_tcase_add_simple_test_const(tcase, "check hive security",
+ test_hive_security);
}
static bool hive_setup_dir(struct torture_context *tctx, void **data)
@@ -363,7 +425,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data)
rmdir(dirname);
- error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key);
+ error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->ev, tctx->lp_ctx, &key);
if (!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to initialize ldb hive\n");
return false;
@@ -381,7 +443,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data)
char *dirname;
NTSTATUS status;
- status = torture_temp_dir(tctx, "hive-dir", &dirname);
+ status = torture_temp_dir(tctx, "hive-regf", &dirname);
if (!NT_STATUS_IS_OK(status))
return false;
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index e5e34c11e0..7274bf009d 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -281,7 +281,8 @@ static bool test_query_key_nums(struct torture_context *tctx, void *_data)
struct registry_key *root, *subkey1, *subkey2;
WERROR error;
uint32_t num_subkeys, num_values;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
if (!create_test_key(tctx, rctx, "Berlin", &root, &subkey1))
return false;
@@ -353,13 +354,15 @@ static bool test_set_value(struct torture_context *tctx, void *_data)
struct registry_context *rctx = (struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
- uint32_t data = 42;
+ char data[4];
+
+ SIVAL(data, 0, 42);
if (!create_test_key(tctx, rctx, "Dusseldorf", &root, &subkey))
return false;
error = reg_val_set(subkey, "Answer", REG_DWORD,
- data_blob_talloc(tctx, &data, sizeof(data)));
+ data_blob_talloc(tctx, data, sizeof(data)));
torture_assert_werr_ok (tctx, error, "setting value");
return true;
@@ -387,11 +390,11 @@ static bool test_security(struct torture_context *tctx, void *_data)
SEC_ACE_FLAG_OBJECT_INHERIT,
NULL);
- error = reg_set_security(subkey, osd);
- torture_assert_werr_ok(tctx, error, "setting security");
+ error = reg_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
- error = reg_get_security(tctx, subkey, &nsd);
- torture_assert_werr_ok (tctx, error, "setting security");
+ error = reg_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
torture_assert(tctx, security_descriptor_equal(osd, nsd),
"security descriptor changed!");
@@ -408,8 +411,9 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
+ char value[4];
uint32_t type;
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Duisburg", &root, &subkey))
return false;
@@ -420,16 +424,16 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
"getting missing value");
error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok(tctx, error, "setting value");
error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__, &type,
&data);
torture_assert_werr_ok(tctx, error, "getting value");
- torture_assert_int_equal(tctx, 4, data.length, "value length ok");
- torture_assert(tctx, memcmp(data.data, &value, 4) == 0,
- "value content ok");
+ torture_assert_int_equal(tctx, sizeof(value), data.length, "value length ok");
+ torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
+ "value content ok");
torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
return true;
@@ -444,8 +448,9 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
uint32_t type;
+ char value[4];
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Warschau", &root, &subkey))
return false;
@@ -456,7 +461,7 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
"getting missing value");
error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok (tctx, error, "setting value");
error = reg_del_value(subkey, __FUNCTION__);
@@ -479,15 +484,16 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
uint32_t type;
const char *name;
+ char value[4];
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Bonn", &root, &subkey))
return false;
error = reg_val_set(subkey, "bar", REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok (tctx, error, "setting value");
error = reg_key_get_value_by_index(tctx, subkey, 0, &name,
@@ -495,8 +501,8 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
torture_assert_werr_ok(tctx, error, "getting value");
torture_assert_str_equal(tctx, name, "bar", "value name");
- torture_assert_int_equal(tctx, 4, data.length, "value length");
- torture_assert(tctx, memcmp(data.data, &value, 4) == 0,
+ torture_assert_int_equal(tctx, sizeof(value), data.length, "value length");
+ torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
"value content");
torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
@@ -517,14 +523,14 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
struct hive_key *hive_key;
const char *filename;
- error = reg_open_local(tctx, &rctx, NULL, NULL);
+ error = reg_open_local(tctx, &rctx);
torture_assert_werr_ok(tctx, error, "Opening local registry failed");
status = torture_temp_dir(tctx, "registry-local", &tempdir);
torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
- error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->lp_ctx, &hive_key);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &hive_key);
torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);