summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/locking.c16
-rw-r--r--source4/torture/config.mk16
-rw-r--r--source4/torture/ldb/ldb.c735
-rw-r--r--source4/torture/local/config.mk2
-rw-r--r--source4/torture/nbt/winsreplication.c12
-rw-r--r--source4/torture/raw/chkpath.c2
-rw-r--r--source4/torture/raw/oplock.c4
-rw-r--r--source4/torture/rpc/netlogon.c21
-rw-r--r--source4/torture/torture.c1
9 files changed, 786 insertions, 23 deletions
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index 3f399c97ef..fcac52ca6a 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -624,10 +624,18 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) &&
torture_comment(tctx, "a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot");
- smbcli_close(cli1->tree, fnum1);
- smbcli_close(cli2->tree, fnum2);
- smbcli_unlink(cli1->tree, fname);
-
+ torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx, "close1 failed (%s)", smbcli_errstr(cli1->tree)));
+
+ torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2),
+ talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli2->tree)));
+
+ torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum3),
+ talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli2->tree)));
+
+ torture_assert_ntstatus_ok(tctx, smbcli_unlink(cli1->tree, fname),
+ talloc_asprintf(tctx, "unlink failed (%s)", smbcli_errstr(cli1->tree)));
+
return correct;
}
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index eaff5d5fda..71fa391003 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -107,7 +107,7 @@ PRIVATE_DEPENDENCIES = \
RPC_NDR_LSA RPC_NDR_EPMAPPER RPC_NDR_DFS RPC_NDR_FRSAPI RPC_NDR_SPOOLSS \
RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_ROT RPC_NDR_DSSETUP \
RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER RPC_NDR_NTSVCS WB_HELPER LIBSAMBA-NET \
- LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \
+ LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_LDB TORTURE_UTIL TORTURE_RAP \
dcerpc_server service process_model ntvfs SERVICE_SMB RPC_NDR_BROWSER
torture_rpc_OBJ_FILES = $(addprefix $(torturesrcdir)/rpc/, \
@@ -191,6 +191,20 @@ TORTURE_LDAP_OBJ_FILES = $(addprefix $(torturesrcdir)/ldap/, common.o basic.o sc
$(eval $(call proto_header_template,$(torturesrcdir)/ldap/proto.h,$(TORTURE_LDAP_OBJ_FILES:.o=.c)))
#################################
+# Start SUBSYSTEM TORTURE_LDB
+[MODULE::TORTURE_LDB]
+SUBSYSTEM = smbtorture
+INIT_FUNCTION = torture_ldb_init
+PRIVATE_DEPENDENCIES = \
+ LDB_WRAP
+# End SUBSYSTEM TORTURE_LDB
+#################################
+
+TORTURE_LDB_OBJ_FILES = $(addprefix $(torturesrcdir)/ldb/, ldb.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/ldb/proto.h,$(TORTURE_LDB_OBJ_FILES:.o=.c)))
+
+#################################
# Start SUBSYSTEM TORTURE_NBT
[MODULE::TORTURE_NBT]
SUBSYSTEM = smbtorture
diff --git a/source4/torture/ldb/ldb.c b/source4/torture/ldb/ldb.c
new file mode 100644
index 0000000000..c2977bcb70
--- /dev/null
+++ b/source4/torture/ldb/ldb.c
@@ -0,0 +1,735 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Test LDB attribute functions
+
+ Copyright (C) Andrew Bartlet <abartlet@samba.org> 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
+ the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "lib/events/events.h"
+#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
+#include "lib/ldb-samba/ldif_handlers.h"
+#include "ldb_wrap.h"
+#include "dsdb/samdb/samdb.h"
+#include "param/param.h"
+#include "torture/smbtorture.h"
+#include "torture/ldb/proto.h"
+
+static const char *sid = "S-1-5-21-4177067393-1453636373-93818737";
+static const char *hex_sid = "01040000000000051500000081FDF8F815BBA456718F9705";
+static const char *guid = "975ac5fa-35d9-431d-b86a-845bcd34fff9";
+static const char *guid2 = "{975ac5fa-35d9-431d-b86a-845bcd34fff9}";
+static const char *hex_guid = "FAC55A97D9351D43B86A845BCD34FFF9";
+
+static bool torture_ldb_attrs(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ struct ldb_context *ldb;
+ const struct ldb_schema_attribute *attr;
+ struct ldb_val string_sid_blob, binary_sid_blob;
+ struct ldb_val string_guid_blob, string_guid_blob2, binary_guid_blob;
+
+ DATA_BLOB sid_blob = strhex_to_data_blob(mem_ctx, hex_sid);
+ DATA_BLOB guid_blob = strhex_to_data_blob(mem_ctx, hex_guid);
+
+ torture_assert(torture,
+ ldb = ldb_init(mem_ctx, torture->ev),
+ "Failed to init ldb");
+
+ torture_assert_int_equal(torture,
+ ldb_register_samba_handlers(ldb), 0,
+ "Failed to register Samba handlers");
+
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+
+ /* Test SID behaviour */
+ torture_assert(torture, attr = ldb_schema_attribute_by_name(ldb, "objectSid"),
+ "Failed to get objectSid schema attribute");
+
+ string_sid_blob = data_blob_string_const(sid);
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_read_fn(ldb, mem_ctx,
+ &string_sid_blob, &binary_sid_blob), 0,
+ "Failed to parse string SID");
+
+ torture_assert_data_blob_equal(torture, binary_sid_blob, sid_blob,
+ "Read SID into blob form failed");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_read_fn(ldb, mem_ctx,
+ &sid_blob, &binary_sid_blob), -1,
+ "Should have failed to parse binary SID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_write_fn(ldb, mem_ctx, &binary_sid_blob, &string_sid_blob), 0,
+ "Failed to parse binary SID");
+
+ torture_assert_data_blob_equal(torture,
+ string_sid_blob, data_blob_string_const(sid),
+ "Write SID into string form failed");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &binary_sid_blob, &string_sid_blob), 0,
+ "Failed to compare binary and string SID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &string_sid_blob, &binary_sid_blob), 0,
+ "Failed to compare string and binary binary SID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &string_sid_blob, &string_sid_blob), 0,
+ "Failed to compare string and string SID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &binary_sid_blob, &binary_sid_blob), 0,
+ "Failed to compare binary and binary SID");
+
+ torture_assert(torture, attr->syntax->comparison_fn(ldb, mem_ctx, &guid_blob, &binary_sid_blob) != 0,
+ "Failed to distinguish binary GUID and binary SID");
+
+
+ /* Test GUID behaviour */
+ torture_assert(torture, attr = ldb_schema_attribute_by_name(ldb, "objectGUID"),
+ "Failed to get objectGUID schema attribute");
+
+ string_guid_blob = data_blob_string_const(guid);
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_read_fn(ldb, mem_ctx,
+ &string_guid_blob, &binary_guid_blob), 0,
+ "Failed to parse string GUID");
+
+ torture_assert_data_blob_equal(torture, binary_guid_blob, guid_blob,
+ "Read GUID into blob form failed");
+
+ string_guid_blob2 = data_blob_string_const(guid2);
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_read_fn(ldb, mem_ctx,
+ &string_guid_blob2, &binary_guid_blob), 0,
+ "Failed to parse string GUID");
+
+ torture_assert_data_blob_equal(torture, binary_guid_blob, guid_blob,
+ "Read GUID into blob form failed");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_read_fn(ldb, mem_ctx,
+ &guid_blob, &binary_guid_blob), 0,
+ "Failed to parse binary GUID");
+
+ torture_assert_data_blob_equal(torture, binary_guid_blob, guid_blob,
+ "Read GUID into blob form failed");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->ldif_write_fn(ldb, mem_ctx, &binary_guid_blob, &string_guid_blob), 0,
+ "Failed to print binary GUID as string");
+
+ torture_assert_data_blob_equal(torture, string_sid_blob, data_blob_string_const(sid),
+ "Write SID into string form failed");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &binary_guid_blob, &string_guid_blob), 0,
+ "Failed to compare binary and string GUID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &string_guid_blob, &binary_guid_blob), 0,
+ "Failed to compare string and binary binary GUID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &string_guid_blob, &string_guid_blob), 0,
+ "Failed to compare string and string GUID");
+
+ torture_assert_int_equal(torture,
+ attr->syntax->comparison_fn(ldb, mem_ctx, &binary_guid_blob, &binary_guid_blob), 0,
+ "Failed to compare binary and binary GUID");
+
+
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
+static bool torture_ldb_dn_attrs(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ struct ldb_context *ldb;
+ const struct ldb_dn_extended_syntax *attr;
+ struct ldb_val string_sid_blob, binary_sid_blob;
+ struct ldb_val string_guid_blob, binary_guid_blob;
+ struct ldb_val hex_sid_blob, hex_guid_blob;
+
+ DATA_BLOB sid_blob = strhex_to_data_blob(mem_ctx, hex_sid);
+ DATA_BLOB guid_blob = strhex_to_data_blob(mem_ctx, hex_guid);
+
+ torture_assert(torture,
+ ldb = ldb_init(mem_ctx, torture->ev),
+ "Failed to init ldb");
+
+ torture_assert_int_equal(torture,
+ ldb_register_samba_handlers(ldb), 0,
+ "Failed to register Samba handlers");
+
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+
+ /* Test SID behaviour */
+ torture_assert(torture, attr = ldb_dn_extended_syntax_by_name(ldb, "SID"),
+ "Failed to get SID DN syntax");
+
+ string_sid_blob = data_blob_string_const(sid);
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &string_sid_blob, &binary_sid_blob), 0,
+ "Failed to parse string SID");
+
+ torture_assert_data_blob_equal(torture, binary_sid_blob, sid_blob,
+ "Read SID into blob form failed");
+
+ hex_sid_blob = data_blob_string_const(hex_sid);
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &hex_sid_blob, &binary_sid_blob), 0,
+ "Failed to parse HEX SID");
+
+ torture_assert_data_blob_equal(torture, binary_sid_blob, sid_blob,
+ "Read SID into blob form failed");
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &sid_blob, &binary_sid_blob), -1,
+ "Should have failed to parse binary SID");
+
+ torture_assert_int_equal(torture,
+ attr->write_hex_fn(ldb, mem_ctx, &sid_blob, &hex_sid_blob), 0,
+ "Failed to parse binary SID");
+
+ torture_assert_data_blob_equal(torture,
+ hex_sid_blob, data_blob_string_const(hex_sid),
+ "Write SID into HEX string form failed");
+
+ torture_assert_int_equal(torture,
+ attr->write_clear_fn(ldb, mem_ctx, &sid_blob, &string_sid_blob), 0,
+ "Failed to parse binary SID");
+
+ torture_assert_data_blob_equal(torture,
+ string_sid_blob, data_blob_string_const(sid),
+ "Write SID into clear string form failed");
+
+
+ /* Test GUID behaviour */
+ torture_assert(torture, attr = ldb_dn_extended_syntax_by_name(ldb, "GUID"),
+ "Failed to get GUID DN syntax");
+
+ string_guid_blob = data_blob_string_const(guid);
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &string_guid_blob, &binary_guid_blob), 0,
+ "Failed to parse string GUID");
+
+ torture_assert_data_blob_equal(torture, binary_guid_blob, guid_blob,
+ "Read GUID into blob form failed");
+
+ hex_guid_blob = data_blob_string_const(hex_guid);
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &hex_guid_blob, &binary_guid_blob), 0,
+ "Failed to parse HEX GUID");
+
+ torture_assert_data_blob_equal(torture, binary_guid_blob, guid_blob,
+ "Read GUID into blob form failed");
+
+ torture_assert_int_equal(torture,
+ attr->read_fn(ldb, mem_ctx,
+ &guid_blob, &binary_guid_blob), -1,
+ "Should have failed to parse binary GUID");
+
+ torture_assert_int_equal(torture,
+ attr->write_hex_fn(ldb, mem_ctx, &guid_blob, &hex_guid_blob), 0,
+ "Failed to parse binary GUID");
+
+ torture_assert_data_blob_equal(torture,
+ hex_guid_blob, data_blob_string_const(hex_guid),
+ "Write GUID into HEX string form failed");
+
+ torture_assert_int_equal(torture,
+ attr->write_clear_fn(ldb, mem_ctx, &guid_blob, &string_guid_blob), 0,
+ "Failed to parse binary GUID");
+
+ torture_assert_data_blob_equal(torture,
+ string_guid_blob, data_blob_string_const(guid),
+ "Write GUID into clear string form failed");
+
+
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
+static bool torture_ldb_dn_extended(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ struct ldb_context *ldb;
+ struct ldb_dn *dn, *dn2;
+
+ DATA_BLOB sid_blob = strhex_to_data_blob(mem_ctx, hex_sid);
+ DATA_BLOB guid_blob = strhex_to_data_blob(mem_ctx, hex_guid);
+
+ const char *dn_str = "cn=admin,cn=users,dc=samba,dc=org";
+
+ torture_assert(torture,
+ ldb = ldb_init(mem_ctx, torture->ev),
+ "Failed to init ldb");
+
+ torture_assert_int_equal(torture,
+ ldb_register_samba_handlers(ldb), 0,
+ "Failed to register Samba handlers");
+
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+
+ /* Check behaviour of a normal DN */
+ torture_assert(torture,
+ dn = ldb_dn_new(mem_ctx, ldb, dn_str),
+ "Failed to create a 'normal' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'normal' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == false,
+ "Should not find plain DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") == NULL,
+ "Should not find an SID on plain DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") == NULL,
+ "Should not find an GUID on plain DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "WKGUID") == NULL,
+ "Should not find an WKGUID on plain DN");
+
+ /* Now make an extended DN */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>;<SID=%s>;%s",
+ guid, sid, dn_str),
+ "Failed to create an 'extended' DN");
+
+ torture_assert(torture,
+ dn2 = ldb_dn_copy(mem_ctx, dn),
+ "Failed to copy the 'extended' DN");
+ talloc_free(dn);
+ dn = dn2;
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'extended' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == true,
+ "Should find extended DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") != NULL,
+ "Should find an SID on extended DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") != NULL,
+ "Should find an GUID on extended DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "SID"), sid_blob,
+ "Extended DN SID incorect");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "GUID"), guid_blob,
+ "Extended DN GUID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), dn_str,
+ "linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_casefold(dn), strupper_talloc(mem_ctx, dn_str),
+ "casefolded DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_component_name(dn, 0), "cn",
+ "componet zero incorrect");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_component_val(dn, 0), data_blob_string_const("admin"),
+ "componet zero incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
+ talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s",
+ guid, sid, dn_str),
+ "Clear extended linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
+ talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s",
+ hex_guid, hex_sid, dn_str),
+ "HEX extended linearized DN incorrect");
+
+ torture_assert(torture, ldb_dn_remove_child_components(dn, 1) == true,
+ "Failed to remove DN child");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == false,
+ "Extended DN flag should be cleared after child element removal");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") == NULL,
+ "Should not find an SID on DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") == NULL,
+ "Should not find an GUID on DN");
+
+
+ /* TODO: test setting these in the other order, and ensure it still comes out 'GUID first' */
+ torture_assert_int_equal(torture, ldb_dn_set_extended_component(dn, "GUID", &guid_blob), 0,
+ "Failed to set a GUID on DN");
+
+ torture_assert_int_equal(torture, ldb_dn_set_extended_component(dn, "SID", &sid_blob), 0,
+ "Failed to set a SID on DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "SID"), sid_blob,
+ "Extended DN SID incorect");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "GUID"), guid_blob,
+ "Extended DN GUID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "cn=users,dc=samba,dc=org",
+ "linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
+ talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s",
+ guid, sid, "cn=users,dc=samba,dc=org"),
+ "Clear extended linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
+ talloc_asprintf(mem_ctx, "<GUID=%s>;<SID=%s>;%s",
+ hex_guid, hex_sid, "cn=users,dc=samba,dc=org"),
+ "HEX extended linearized DN incorrect");
+
+ /* Now check a 'just GUID' DN (clear format) */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>",
+ guid),
+ "Failed to create an 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'extended' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == true,
+ "Should find extended DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") == NULL,
+ "Should not find an SID on this DN");
+
+ torture_assert_int_equal(torture, ldb_dn_get_comp_num(dn), 0,
+ "Should not find an 'normal' componet on this DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") != NULL,
+ "Should find an GUID on this DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "GUID"), guid_blob,
+ "Extended DN GUID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "",
+ "linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
+ talloc_asprintf(mem_ctx, "<GUID=%s>",
+ guid),
+ "Clear extended linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
+ talloc_asprintf(mem_ctx, "<GUID=%s>",
+ hex_guid),
+ "HEX extended linearized DN incorrect");
+
+ /* Now check a 'just GUID' DN (HEX format) */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>",
+ hex_guid),
+ "Failed to create an 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'extended' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == true,
+ "Should find extended DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") == NULL,
+ "Should not find an SID on this DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") != NULL,
+ "Should find an GUID on this DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "GUID"), guid_blob,
+ "Extended DN GUID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "",
+ "linearized DN incorrect");
+
+ /* Now check a 'just SID' DN (clear format) */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<SID=%s>",
+ sid),
+ "Failed to create an 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'extended' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == true,
+ "Should find extended DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") == NULL,
+ "Should not find an SID on this DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") != NULL,
+ "Should find an SID on this DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "SID"), sid_blob,
+ "Extended DN SID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "",
+ "linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 1),
+ talloc_asprintf(mem_ctx, "<SID=%s>",
+ sid),
+ "Clear extended linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0),
+ talloc_asprintf(mem_ctx, "<SID=%s>",
+ hex_sid),
+ "HEX extended linearized DN incorrect");
+
+ /* Now check a 'just SID' DN (HEX format) */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<SID=%s>",
+ hex_sid),
+ "Failed to create an 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate 'extended' DN");
+
+ torture_assert(torture, ldb_dn_has_extended(dn) == true,
+ "Should find extended DN to be 'extended'");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "GUID") == NULL,
+ "Should not find an SID on this DN");
+
+ torture_assert(torture, ldb_dn_get_extended_component(dn, "SID") != NULL,
+ "Should find an SID on this DN");
+
+ torture_assert_data_blob_equal(torture, *ldb_dn_get_extended_component(dn, "SID"), sid_blob,
+ "Extended DN SID incorect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "",
+ "linearized DN incorrect");
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
+
+static bool torture_ldb_dn(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ struct ldb_context *ldb;
+ struct ldb_dn *dn;
+ struct ldb_dn *child_dn;
+ struct ldb_dn *typo_dn;
+
+ torture_assert(torture,
+ ldb = ldb_init(mem_ctx, torture->ev),
+ "Failed to init ldb");
+
+ torture_assert_int_equal(torture,
+ ldb_register_samba_handlers(ldb), 0,
+ "Failed to register Samba handlers");
+
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+
+ /* Check behaviour of a normal DN */
+ torture_assert(torture,
+ dn = ldb_dn_new(mem_ctx, ldb, NULL),
+ "Failed to create a NULL DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn),
+ "Failed to validate NULL DN");
+
+ torture_assert(torture,
+ ldb_dn_add_base_fmt(dn, "dc=org"),
+ "Failed to add base DN");
+
+ torture_assert(torture,
+ ldb_dn_add_child_fmt(dn, "dc=samba"),
+ "Failed to add base DN");
+
+ torture_assert_str_equal(torture, ldb_dn_get_linearized(dn), "dc=samba,dc=org",
+ "linearized DN incorrect");
+
+ torture_assert_str_equal(torture, ldb_dn_get_extended_linearized(mem_ctx, dn, 0), "dc=samba,dc=org",
+ "extended linearized DN incorrect");
+
+ /* Check child DN comparisons */
+ torture_assert(torture,
+ child_dn = ldb_dn_new(mem_ctx, ldb, "CN=users,DC=SAMBA,DC=org"),
+ "Failed to create child DN");
+
+ torture_assert(torture,
+ ldb_dn_compare(dn, child_dn) != 0,
+ "Comparison on dc=samba,dc=org and CN=users,DC=SAMBA,DC=org should != 0");
+
+ torture_assert(torture,
+ ldb_dn_compare_base(child_dn, dn) != 0,
+ "Base Comparison of CN=users,DC=SAMBA,DC=org and dc=samba,dc=org should != 0");
+
+ torture_assert(torture,
+ ldb_dn_compare_base(dn, child_dn) == 0,
+ "Base Comparison on dc=samba,dc=org and CN=users,DC=SAMBA,DC=org should == 0");
+
+ /* Check comparisons with a truncated DN */
+ torture_assert(torture,
+ typo_dn = ldb_dn_new(mem_ctx, ldb, "c=samba,dc=org"),
+ "Failed to create 'typo' DN");
+
+ torture_assert(torture,
+ ldb_dn_compare(dn, typo_dn) != 0,
+ "Comparison on dc=samba,dc=org and c=samba,dc=org should != 0");
+
+ torture_assert(torture,
+ ldb_dn_compare_base(typo_dn, dn) != 0,
+ "Base Comparison of c=samba,dc=org and dc=samba,dc=org should != 0");
+
+ torture_assert(torture,
+ ldb_dn_compare_base(dn, typo_dn) != 0,
+ "Base Comparison on dc=samba,dc=org and c=samba,dc=org should != 0");
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
+static bool torture_ldb_dn_invalid_extended(struct torture_context *torture)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(torture);
+ struct ldb_context *ldb;
+ struct ldb_dn *dn;
+
+ const char *dn_str = "cn=admin,cn=users,dc=samba,dc=org";
+
+ torture_assert(torture,
+ ldb = ldb_init(mem_ctx, torture->ev),
+ "Failed to init ldb");
+
+ torture_assert_int_equal(torture,
+ ldb_register_samba_handlers(ldb), 0,
+ "Failed to register Samba handlers");
+
+ ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
+
+ /* Check behaviour of a normal DN */
+ torture_assert(torture,
+ dn = ldb_dn_new(mem_ctx, ldb, "samba,dc=org"),
+ "Failed to create a 'normal' invalid DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'normal' invalid DN");
+
+ /* Now make an extended DN */
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<PID=%s>;%s",
+ sid, dn_str),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>%s",
+ sid, dn_str),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>;",
+ sid),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=%s>;",
+ hex_sid),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<SID=%s>;",
+ hex_guid),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<SID=%s>;",
+ guid),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ torture_assert(torture,
+ dn = ldb_dn_new_fmt(mem_ctx, ldb, "<GUID=>"),
+ "Failed to create an invalid 'extended' DN");
+
+ torture_assert(torture,
+ ldb_dn_validate(dn) == false,
+ "should have failed to validate 'extended' DN");
+
+ return true;
+}
+
+NTSTATUS torture_ldb_init(void)
+{
+ struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "LDB");
+ torture_suite_add_simple_test(suite, "ATTRS", torture_ldb_attrs);
+ torture_suite_add_simple_test(suite, "DN-ATTRS", torture_ldb_dn_attrs);
+ torture_suite_add_simple_test(suite, "DN-EXTENDED", torture_ldb_dn_extended);
+ torture_suite_add_simple_test(suite, "DN-INVALID-EXTENDED", torture_ldb_dn_invalid_extended);
+ torture_suite_add_simple_test(suite, "DN", torture_ldb_dn);
+
+ suite->description = talloc_strdup(suite, "LDB (samba-specific behaviour) tests");
+
+ torture_register_suite(suite);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index 46d5e38e67..60cbf25eda 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -43,7 +43,7 @@ TORTURE_LOCAL_OBJ_FILES = \
$(torturesrcdir)/../../lib/util/charset/tests/charset.o \
$(torturesrcdir)/../libcli/security/tests/sddl.o \
$(torturesrcdir)/../lib/tdr/testsuite.o \
- $(torturesrcdir)/../lib/events/testsuite.o \
+ $(torturesrcdir)/../../lib/tevent/testsuite.o \
$(torturesrcdir)/../param/tests/share.o \
$(torturesrcdir)/../param/tests/loadparm.o \
$(torturesrcdir)/../auth/credentials/tests/simple.o \
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index b688f1fbfe..ca557de8fe 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -107,10 +107,10 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup 2 wrepl connections\n");
- status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
+ status = wrepl_connect(wrepl_socket1, wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
- status = wrepl_connect(wrepl_socket2, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
+ status = wrepl_connect(wrepl_socket2, wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send a start association request (conn1)\n");
@@ -189,7 +189,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
+ status = wrepl_connect(wrepl_socket, wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send 1st start association request\n");
@@ -258,7 +258,7 @@ static bool test_wins_replication(struct torture_context *tctx)
wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
+ status = wrepl_connect(wrepl_socket, wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send a start association request\n");
@@ -557,7 +557,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
if (!ctx->pull) return NULL;
torture_comment(tctx, "Setup wrepl conflict pull connection\n");
- status = wrepl_connect(ctx->pull, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
+ status = wrepl_connect(ctx->pull, wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
if (!NT_STATUS_IS_OK(status)) return NULL;
status = wrepl_associate(ctx->pull, &associate);
@@ -724,7 +724,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
+ status = wrepl_connect(wrepl_socket, wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
status = wrepl_associate(wrepl_socket, &associate);
diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c
index b66839b997..a39993489b 100644
--- a/source4/torture/raw/chkpath.c
+++ b/source4/torture/raw/chkpath.c
@@ -306,7 +306,7 @@ static bool test_chkpath_names(struct smbcli_state *cli, struct torture_context
case '?':/*0x3F*/
case '|':/*0x7C*/
if (i == '/' &&
- torture_setting_bool(tctx, "samba3", true)) {
+ torture_setting_bool(tctx, "samba3", false)) {
/* samba 3 handles '/' as '\\' */
break;
}
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 4ffb24eb03..f0afee26cc 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -2632,10 +2632,6 @@ static bool test_raw_oplock_batch23(struct torture_context *tctx, struct smbcli_
uint16_t fnum=0, fnum2=0,fnum3=0;
struct smbcli_state *cli3 = NULL;
- if (torture_setting_bool(tctx, "samba3", false)) {
- torture_skip(tctx, "BATCH23 disabled against samba3\n");
- }
-
if (!torture_setup_dir(cli1, BASEDIR)) {
return false;
}
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index 306c271511..c7518d15a0 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -1688,13 +1688,16 @@ static bool test_LogonControl2Ex(struct torture_context *tctx,
{
NTSTATUS status;
struct netr_LogonControl2Ex r;
+ union netr_CONTROL_DATA_INFORMATION data;
union netr_CONTROL_QUERY_INFORMATION query;
int i;
+ data.domain = lp_workgroup(tctx->lp_ctx);
+
r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
r.in.function_code = NETLOGON_CONTROL_REDISCOVER;
- r.in.data.domain = lp_workgroup(tctx->lp_ctx);
+ r.in.data = &data;
r.out.query = &query;
for (i=1;i<4;i++) {
@@ -1707,8 +1710,10 @@ static bool test_LogonControl2Ex(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
+ data.domain = lp_workgroup(tctx->lp_ctx);
+
r.in.function_code = NETLOGON_CONTROL_TC_QUERY;
- r.in.data.domain = lp_workgroup(tctx->lp_ctx);
+ r.in.data = &data;
for (i=1;i<4;i++) {
r.in.level = i;
@@ -1720,8 +1725,10 @@ static bool test_LogonControl2Ex(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
+ data.domain = lp_workgroup(tctx->lp_ctx);
+
r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY;
- r.in.data.domain = lp_workgroup(tctx->lp_ctx);
+ r.in.data = &data;
for (i=1;i<4;i++) {
r.in.level = i;
@@ -1733,8 +1740,10 @@ static bool test_LogonControl2Ex(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "LogonControl");
}
+ data.debug_level = ~0;
+
r.in.function_code = NETLOGON_CONTROL_SET_DBFLAG;
- r.in.data.debug_level = ~0;
+ r.in.data = &data;
for (i=1;i<4;i++) {
r.in.level = i;
@@ -2128,7 +2137,7 @@ static bool test_GetDomainInfo(struct torture_context *tctx,
q1.workstation_site = "Default-First-Site-Name";
q1.blob2.length = 0;
q1.blob2.size = 0;
- q1.blob2.data = NULL;
+ q1.blob2.array = NULL;
q1.product.string = "product string";
torture_comment(tctx, "Testing netr_LogonGetDomainInfo\n");
@@ -2194,7 +2203,7 @@ static bool test_GetDomainInfo_async(struct torture_context *tctx,
q1.workstation_site = "Default-First-Site-Name";
q1.blob2.length = 0;
q1.blob2.size = 0;
- q1.blob2.data = NULL;
+ q1.blob2.array = NULL;
q1.product.string = "product string";
torture_comment(tctx, "Testing netr_LogonGetDomainInfo - async count %d\n", ASYNC_COUNT);
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index dc98c2cc9a..3f9a6607cf 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -50,6 +50,7 @@ _PUBLIC_ int torture_init(void)
{
extern NTSTATUS torture_base_init(void);
extern NTSTATUS torture_ldap_init(void);
+ extern NTSTATUS torture_ldb_init(void);
extern NTSTATUS torture_local_init(void);
extern NTSTATUS torture_nbt_init(void);
extern NTSTATUS torture_nbench_init(void);