summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/librpc/idl/winreg.idl2
-rw-r--r--source4/torture/config.mk7
-rw-r--r--source4/torture/ndr/ndr.c94
-rw-r--r--source4/torture/ndr/ndr.h45
-rw-r--r--source4/torture/ndr/winreg.c48
5 files changed, 195 insertions, 1 deletions
diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl
index 16dd55d151..d67017d331 100644
--- a/source4/librpc/idl/winreg.idl
+++ b/source4/librpc/idl/winreg.idl
@@ -89,7 +89,7 @@ import "lsa.idl", "initshutdown.idl", "security.idl";
/******************/
/* Function: 0x05 */
- WERROR winreg_CloseKey(
+ [public] WERROR winreg_CloseKey(
[in,out,ref] policy_handle *handle
);
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 05435e782d..e3d6cef5ae 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -96,6 +96,13 @@ PRIVATE_DEPENDENCIES = TORTURE_UTIL
include smb2/config.mk
+[MODULE::torture_ndr]
+SUBSYSTEM = torture
+INIT_FUNCTION = torture_ndr_init
+PRIVATE_PROTO_HEADER = ndr/proto.h
+OBJ_FILES = ndr/ndr.o \
+ ndr/winreg.o
+
[MODULE::torture_rpc]
# TORTURE_NET and TORTURE_NBT use functions from torture_rpc...
#OUTPUT_TYPE = INTEGRATED
diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c
new file mode 100644
index 0000000000..c1179395c1
--- /dev/null
+++ b/source4/torture/ndr/ndr.c
@@ -0,0 +1,94 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for winreg ndr operations
+
+ Copyright (C) Jelmer Vernooij 2007
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "torture/ndr/ndr.h"
+#include "torture/ndr/proto.h"
+#include "util/dlinklist.h"
+
+struct ndr_pull_test_data {
+ DATA_BLOB data;
+ size_t struct_size;
+ ndr_pull_flags_fn_t pull_fn;
+ int ndr_flags;
+};
+
+static bool wrap_ndr_pull_test(struct torture_context *tctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn;
+ const struct ndr_pull_test_data *data = test->data;
+ void *ds = talloc_zero_size(tctx, data->struct_size);
+ struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx);
+
+ ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
+
+ torture_assert_ntstatus_ok(tctx, data->pull_fn(ndr, data->ndr_flags, ds),
+ "pulling");
+
+ return check_fn(tctx, ds);
+}
+
+_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test(
+ struct torture_suite *suite,
+ const char *name, ndr_pull_flags_fn_t pull_fn,
+ DATA_BLOB db,
+ size_t struct_size,
+ int ndr_flags,
+ bool (*check_fn) (struct torture_context *ctx, void *data))
+{
+ struct torture_test *test;
+ struct torture_tcase *tcase;
+ struct ndr_pull_test_data *data;
+
+ tcase = torture_suite_add_tcase(suite, name);
+
+ test = talloc(tcase, struct torture_test);
+
+ test->name = talloc_strdup(test, name);
+ test->description = NULL;
+ test->run = wrap_ndr_pull_test;
+ data = talloc(test, struct ndr_pull_test_data);
+ data->data = db;
+ data->ndr_flags = ndr_flags;
+ data->struct_size = struct_size;
+ data->pull_fn = pull_fn;
+ test->data = data;
+ test->fn = check_fn;
+ test->dangerous = false;
+
+ DLIST_ADD_END(tcase->tests, test, struct torture_test *);
+
+ return test;
+}
+
+NTSTATUS torture_ndr_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "NDR");
+
+ torture_suite_add_suite(suite, ndr_winreg_suite(suite));
+
+ torture_register_suite(suite);
+
+ return NT_STATUS_OK;
+}
+
diff --git a/source4/torture/ndr/ndr.h b/source4/torture/ndr/ndr.h
new file mode 100644
index 0000000000..6d3a840034
--- /dev/null
+++ b/source4/torture/ndr/ndr.h
@@ -0,0 +1,45 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture tester
+ Copyright (C) Jelmer Vernooij 2007
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __TORTURE_NDR_H__
+#define __TORTURE_NDR_H__
+
+#include "torture/torture.h"
+#include "librpc/ndr/libndr.h"
+
+_PUBLIC_ struct torture_test *_torture_suite_add_ndr_pull_test(
+ struct torture_suite *suite,
+ const char *name, ndr_pull_flags_fn_t fn,
+ DATA_BLOB db,
+ size_t struct_size,
+ int ndr_flags,
+ bool (*check_fn) (struct torture_context *, void *data));
+
+#define torture_suite_add_ndr_pull_test(suite,name,data,check_fn) \
+ _torture_suite_add_ndr_pull_test(suite, #name, \
+ (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \
+ sizeof(struct name), 0, (bool (*) (struct torture_context *, void *)) check_fn);
+
+#define torture_suite_add_ndr_pull_fn_test(suite,name,data,flags,check_fn) \
+ _torture_suite_add_ndr_pull_test(suite, #name, \
+ (ndr_pull_flags_fn_t)ndr_pull_ ## name, data_blob_talloc(suite, data, sizeof(data)), \
+ sizeof(struct name), flags, (bool (*) (struct torture_context *, void *)) check_fn);
+
+#endif /* __TORTURE_NDR_H__ */
diff --git a/source4/torture/ndr/winreg.c b/source4/torture/ndr/winreg.c
new file mode 100644
index 0000000000..e5088ab045
--- /dev/null
+++ b/source4/torture/ndr/winreg.c
@@ -0,0 +1,48 @@
+/*
+ Unix SMB/CIFS implementation.
+ test suite for winreg ndr operations
+
+ Copyright (C) Jelmer Vernooij 2007
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "torture/ndr/ndr.h"
+#include "librpc/gen_ndr/ndr_winreg.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libcli/security/security.h"
+
+static const uint8_t winreg_closekey_data[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48,
+ 0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
+};
+
+static bool winreg_closekey_check(struct torture_context *tctx,
+ struct winreg_CloseKey *ck)
+{
+ torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
+ torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
+ return true;
+}
+
+struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
+{
+ struct torture_suite *suite = torture_suite_create(ctx, "winreg");
+
+ torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, winreg_closekey_data, NDR_IN, winreg_closekey_check );
+
+ return suite;
+}