From 9e6fb5a53994c827d9c595eee68be29962bda9db Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Sep 2012 20:40:13 +1000 Subject: [PATCH 1/7] selftest: use an array when starting testenv with system() By reduing the need for escapes and forcing the use of bash, this seems to allow 'make testenv' to start on FreeBSD Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Sun Sep 30 02:30:40 CEST 2012 on sn-devel-104 --- selftest/selftest.pl | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index c063f32..ffb6149 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -846,8 +846,13 @@ if ($opt_testenv) { my $envvarstr = exported_envvars_str($testenv_vars); - my $term = ($ENV{TERMINAL} or "xterm -e"); - system("$term 'echo -e \" + my @term = (); + if ($ENV{TERMINAL}) { + @term = ($ENV{TERMINAL}); + } else { + @term = ("xterm", "-e"); + } + my @term_args = ("bash", "-c", "echo -e \" Welcome to the Samba4 Test environment '$testenv_name' This matches the client environment used in make test @@ -858,7 +863,10 @@ TORTURE_OPTIONS=\$TORTURE_OPTIONS SMB_CONF_PATH=\$SMB_CONF_PATH $envvarstr -\" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'"); +\" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash"); + + system(@term, @term_args); + teardown_env($testenv_name); } elsif ($opt_list) { foreach (@todo) { -- 1.7.7 From 42db0158aea821117251ea7dff262d75f2d6aa56 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Sep 2012 09:39:15 -0700 Subject: [PATCH 2/7] Add samba3.samba3badnameblob test to check regressions in bug #9215. Bad name in SMB1 openX can cause a crash in iconv inside glibc. Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Oct 1 23:29:25 CEST 2012 on sn-devel-104 --- source3/selftest/tests.py | 2 +- source4/torture/raw/raw.c | 1 + source4/torture/raw/samba3misc.c | 138 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletions(-) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index dac86e9..9b0527c 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -253,7 +253,7 @@ raw = ["raw.acls", "raw.chkpath", "raw.close", "raw.composite", "raw.context", " "raw.samba3caseinsensitive", "raw.samba3posixtimedlock", "raw.samba3rootdirfid", "raw.sfileinfo.end-of-file", "raw.bench-oplock", "raw.bench-lock", "raw.bench-open", "raw.bench-tcon", - "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff"] + "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff", "raw.samba3badnameblob"] smb2 = smbtorture4_testsuites("smb2.") diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index 9686efa..bda463b 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -69,6 +69,7 @@ NTSTATUS torture_raw_init(void) torture_samba3_rootdirfid); torture_suite_add_1smb_test(suite, "samba3checkfsp", torture_samba3_checkfsp); torture_suite_add_1smb_test(suite, "samba3oplocklogoff", torture_samba3_oplock_logoff); + torture_suite_add_1smb_test(suite, "samba3badnameblob", torture_samba3_check_openX_badname); torture_suite_add_simple_test(suite, "samba3badpath", torture_samba3_badpath); torture_suite_add_1smb_test(suite, "samba3caseinsensitive", torture_samba3_caseinsensitive); diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c index 2004385..a818c6b 100644 --- a/source4/torture/raw/samba3misc.c +++ b/source4/torture/raw/samba3misc.c @@ -29,6 +29,126 @@ #include "param/param.h" #include "torture/raw/proto.h" +/* + The next 2 functions are stolen from source4/libcli/raw/rawfile.c + but allow us to send a raw data blob instead of an OpenX name. +*/ + +#define SETUP_REQUEST(cmd, wct, buflen) do { \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ + if (!req) return NULL; \ +} while (0) + +static struct smbcli_request *smb_raw_openX_name_blob_send(struct smbcli_tree *tree, + union smb_open *parms, + const DATA_BLOB *pname_blob) +{ + struct smbcli_request *req = NULL; + + if (parms->generic.level != RAW_OPEN_OPENX) { + return NULL; + } + + SETUP_REQUEST(SMBopenX, 15, 0); + SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE); + SSVAL(req->out.vwv, VWV(1), 0); + SSVAL(req->out.vwv, VWV(2), parms->openx.in.flags); + SSVAL(req->out.vwv, VWV(3), parms->openx.in.open_mode); + SSVAL(req->out.vwv, VWV(4), parms->openx.in.search_attrs); + SSVAL(req->out.vwv, VWV(5), parms->openx.in.file_attrs); + raw_push_dos_date3(tree->session->transport, + req->out.vwv, VWV(6), parms->openx.in.write_time); + SSVAL(req->out.vwv, VWV(8), parms->openx.in.open_func); + SIVAL(req->out.vwv, VWV(9), parms->openx.in.size); + SIVAL(req->out.vwv, VWV(11),parms->openx.in.timeout); + SIVAL(req->out.vwv, VWV(13),0); /* reserved */ + smbcli_req_append_blob(req, pname_blob); + + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); + return NULL; + } + + return req; +} + +static NTSTATUS smb_raw_openX_name_blob(struct smbcli_tree *tree, + TALLOC_CTX *mem_ctx, + union smb_open *parms, + const DATA_BLOB *pname_blob) +{ + struct smbcli_request *req = smb_raw_openX_name_blob_send(tree, parms, pname_blob); + return smb_raw_open_recv(req, mem_ctx, parms); +} + +static NTSTATUS raw_smbcli_openX_name_blob(struct smbcli_tree *tree, + const DATA_BLOB *pname_blob, + int flags, + int share_mode, + int *fnum) +{ + union smb_open open_parms; + unsigned int openfn=0; + unsigned int accessmode=0; + TALLOC_CTX *mem_ctx; + NTSTATUS status; + + mem_ctx = talloc_init("raw_openX_name_blob"); + if (!mem_ctx) return NT_STATUS_NO_MEMORY; + + if (flags & O_CREAT) { + openfn |= OPENX_OPEN_FUNC_CREATE; + } + if (!(flags & O_EXCL)) { + if (flags & O_TRUNC) { + openfn |= OPENX_OPEN_FUNC_TRUNC; + } else { + openfn |= OPENX_OPEN_FUNC_OPEN; + } + } + + accessmode = (share_mode<tree, NULL, 65535); + + if (name_blob.data == NULL) { + return false; + } + memset(name_blob.data, 0xcc, 65535); + status = raw_smbcli_openX_name_blob(cli->tree, &name_blob, O_RDWR, DENY_NONE, &fnum); + CHECK_STATUS(tctx, status, NT_STATUS_OBJECT_NAME_INVALID); + ret = true; + + return ret; +} -- 1.7.7 From c576e60c63ddee0e62499c4c7e92eadf32e1bed9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 1 Oct 2012 08:51:47 +0200 Subject: [PATCH 3/7] s4:tortore/rpc/lsa: make more use of torture_assert* Currently samba3.rpc.lsa.privileges.lsa.Privileges(s3dc) seems to be flakey. We may be able to find the bug with this, or at least mark it as flapping. metze --- source4/torture/rpc/lsa.c | 87 ++++++++++++++++++++------------------------ 1 files changed, 40 insertions(+), 47 deletions(-) diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index 942dd52..041cbec 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -158,9 +158,7 @@ bool test_lsa_OpenPolicy2_ex(struct dcerpc_binding_handle *b, torture_comment(tctx, "\nTesting OpenPolicy2\n"); *handle = talloc(tctx, struct policy_handle); - if (!*handle) { - return false; - } + torture_assert(tctx, *handle != NULL, "talloc(tctx, struct policy_handle)"); qos.len = 0; qos.impersonation_level = 2; @@ -321,36 +319,37 @@ static bool test_LookupNames(struct dcerpc_binding_handle *b, tnames->names[i].name.string); } } - torture_comment(tctx, "LookupNames failed - %s\n", - nt_errstr(r.out.result)); - return false; + torture_assert_ntstatus_ok(tctx, r.out.result, + "LookupNames failed"); } else if (!NT_STATUS_IS_OK(r.out.result)) { - torture_comment(tctx, "LookupNames failed - %s\n", - nt_errstr(r.out.result)); - return false; + torture_assert_ntstatus_ok(tctx, r.out.result, + "LookupNames failed"); } for (i=0;i< r.in.num_names;i++) { - if (i < count) { - if (sids.sids[i].sid_type != tnames->names[input_idx[i]].sid_type) { - torture_comment(tctx, "LookupName of %s got unexpected name type: %s\n", - tnames->names[input_idx[i]].name.string, - sid_type_lookup(sids.sids[i].sid_type)); - return false; - } - if ((sids.sids[i].sid_type == SID_NAME_DOMAIN) && - (sids.sids[i].rid != (uint32_t)-1)) { - torture_comment(tctx, "LookupName of %s got unexpected rid: %d\n", - tnames->names[input_idx[i]].name.string, sids.sids[i].rid); - return false; - } - } else if (i >=count) { - torture_comment(tctx, "LookupName of %s failed to return a result\n", - tnames->names[input_idx[i]].name.string); - return false; + torture_assert(tctx, (i < count), + talloc_asprintf(tctx, + "LookupName of %s failed to return a result\n", + tnames->names[input_idx[i]].name.string)); + + torture_assert_int_equal(tctx, + sids.sids[i].sid_type, + tnames->names[input_idx[i]].sid_type, + talloc_asprintf(tctx, + "LookupName of %s got unexpected name type: %s\n", + tnames->names[input_idx[i]].name.string, + sid_type_lookup(sids.sids[i].sid_type))); + if (sids.sids[i].sid_type != SID_NAME_DOMAIN) { + continue; } + torture_assert_int_equal(tctx, + sids.sids[i].rid, + UINT32_MAX, + talloc_asprintf(tctx, + "LookupName of %s got unexpected rid: %d\n", + tnames->names[input_idx[i]].name.string, + sids.sids[i].rid)); } - torture_comment(tctx, "\n"); return true; } @@ -783,11 +782,9 @@ static bool test_LookupSids(struct dcerpc_binding_handle *b, torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids_r(b, tctx, &r), "LookupSids failed"); - if (!NT_STATUS_IS_OK(r.out.result) && - !NT_STATUS_EQUAL(r.out.result, STATUS_SOME_UNMAPPED)) { - torture_comment(tctx, "LookupSids failed - %s\n", - nt_errstr(r.out.result)); - return false; + if (!NT_STATUS_EQUAL(r.out.result, STATUS_SOME_UNMAPPED)) { + torture_assert_ntstatus_ok(tctx, r.out.result, + "LookupSids failed"); } torture_comment(tctx, "\n"); @@ -1375,10 +1372,8 @@ static bool test_Delete(struct dcerpc_binding_handle *b, r.in.handle = handle; torture_assert_ntstatus_ok(tctx, dcerpc_lsa_Delete_r(b, tctx, &r), "Delete failed"); - if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_NOT_SUPPORTED)) { - torture_comment(tctx, "Delete should have failed NT_STATUS_NOT_SUPPORTED - %s\n", nt_errstr(r.out.result)); - return false; - } + torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_NOT_SUPPORTED, + "Delete should have failed NT_STATUS_NOT_SUPPORTED"); return true; } @@ -3662,46 +3657,44 @@ struct torture_suite *torture_rpc_lsa_trusted_domains(TALLOC_CTX *mem_ctx) static bool testcase_Privileges(struct torture_context *tctx, struct dcerpc_pipe *p) { - bool ret = true; struct policy_handle *handle; struct dcerpc_binding_handle *b = p->binding_handle; if (p->binding->transport != NCACN_NP && p->binding->transport != NCALRPC) { - torture_comment(tctx, "testcase_Privileges is only available " + torture_skip(tctx, "testcase_Privileges is only available " "over NCACN_NP or NCALRPC"); - return true; } if (!test_OpenPolicy(b, tctx)) { - ret = false; + return false; } if (!test_lsa_OpenPolicy2(b, tctx, &handle)) { - ret = false; + return false; } if (!handle) { - ret = false; + return false; } if (!test_CreateAccount(b, tctx, handle)) { - ret = false; + return false; } if (!test_EnumAccounts(b, tctx, handle)) { - ret = false; + return false; } if (!test_EnumPrivs(b, tctx, handle)) { - ret = false; + return false; } if (!test_lsa_Close(b, tctx, handle)) { - ret = false; + return false; } - return ret; + return true; } -- 1.7.7 From c85de988378445a0cd4c043a7d87006194b5ba24 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Oct 2012 08:34:35 +0200 Subject: [PATCH 4/7] selftest/knownfail: add samba3.rpc.lsa.privileges.lsa.Privileges This failed more than 20 times in the last few weeks, e.g. https://git.samba.org/autobuild.flakey/2012-10-16-0629/samba3.stdout https://git.samba.org/autobuild.flakey/2012-10-16-0829/samba3.stdout [530/717 in 14m32s] samba3.rpc.lsa.privileges(s3dc) Using seed 1350368974 Testing OpenPolicy Testing OpenPolicy2 Testing CreateAccount Testing Delete Testing DeleteObject Testing EnumAccounts Testing LookupSids Testing LookupNames with 7 names LookupName of sharesec_user was unmapped LookupName of Everyone failed to return a result UNEXPECTED(failure): samba3.rpc.lsa.privileges.lsa.Privileges(s3dc) REASON: _StringException: _StringException: ../source4/torture/rpc/lsa.c:319: r.out.result was STATUS_SOME_UNMAPPED, expected NT_STATUS_OK: LookupNames failed FAILED (1 failures, 0 errors and 0 unexpected successes in 0 testsuites) metze Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Tue Oct 16 10:43:02 CEST 2012 on sn-devel-104 (cherry picked from commit 1861213d147e0d96fd637813c5badb4908ec14d1) --- selftest/flapping | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/selftest/flapping b/selftest/flapping index f0b1528..afeae65 100644 --- a/selftest/flapping +++ b/selftest/flapping @@ -15,6 +15,7 @@ ^samba3.rpc.spoolss.printer.*addprinterex.print_test # another intermittent failure ^samba3.rap.printing # fails sometimes on sn-devel ^samba3.rpc.spoolss.printer.*addprinter.print_test # fails on some hosts due to timing issues ? +^samba3.rpc.lsa.privileges.lsa.Privileges\(s3dc\) # fails sometimes on sn-devel ^samba3.smb2.lock.*.rw-exclusive # another intermittent failure ^samba4.blackbox.gentest # is flakey due to timing ^samba3.smb2.acls.INHERITANCE\(plugin_s4_dc\) # Seems to flap - succeeds on sn-devel, fails on Fedora 16 -- 1.7.7 From e43ac259e74771e4b8fc3f52a45e9cd14592274d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Nov 2012 14:13:16 +0100 Subject: [PATCH 5/7] s4:torture/rpc/handles: move a torture_comment() Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 14ee2cd938a963d5b3398eed4f21ff64630afdcd) --- source4/torture/rpc/handles.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source4/torture/rpc/handles.c b/source4/torture/rpc/handles.c index 6b51eb5..9dfa1c0 100644 --- a/source4/torture/rpc/handles.c +++ b/source4/torture/rpc/handles.c @@ -504,11 +504,12 @@ static bool test_handles_random_assoc(struct torture_context *torture) status = torture_rpc_connection(torture, &p1, &ndr_table_samr); torture_assert_ntstatus_ok(torture, status, "opening samr pipe1"); + torture_comment(torture, "pipe1 uses assoc_group_id[0x%08X]\n", + p1->assoc_group_id); + transport = p1->conn->transport.transport; assoc_group_id = p1->assoc_group_id; - torture_comment(torture, "pipe1 uses assoc_group_id[0x%08X]\n", assoc_group_id); - torture_comment(torture, "connect samr pipe2 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id); status = torture_rpc_connection_transport(torture, &p2, &ndr_table_samr, transport, -- 1.7.7 From 10200d49eb6825cab4ca6641df7e4af7655dd64c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 14 Nov 2012 08:45:10 +0100 Subject: [PATCH 6/7] s4:torture/rpc/handles: try to make the assoc_group test less flakey Just incrementing the assoc_group_id makes it too likely to hit a number that is already in use. Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam (cherry picked from commit 6568a26f0142950300ae8503b8bc2bffb8a77352) --- source4/torture/rpc/handles.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/source4/torture/rpc/handles.c b/source4/torture/rpc/handles.c index 9dfa1c0..3fdce56 100644 --- a/source4/torture/rpc/handles.c +++ b/source4/torture/rpc/handles.c @@ -508,7 +508,11 @@ static bool test_handles_random_assoc(struct torture_context *torture) p1->assoc_group_id); transport = p1->conn->transport.transport; - assoc_group_id = p1->assoc_group_id; + /* + * We use ~p1->assoc_group_id instead of p1->assoc_group_id, because + * this way we are less likely to use an id which is already in use. + */ + assoc_group_id = ~p1->assoc_group_id; torture_comment(torture, "connect samr pipe2 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id); status = torture_rpc_connection_transport(torture, &p2, &ndr_table_samr, -- 1.7.7 From 7322788b58d44280f15ed3d327f99b717d21b802 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 24 Nov 2012 11:28:57 +0100 Subject: [PATCH 7/7] s4:torture/rpc/handles: try to make all assoc_group tests less flakey Just incrementing the assoc_group_id makes it too likely to hit a number that is already in use. Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Mon Nov 26 13:53:22 CET 2012 on sn-devel-104 (cherry picked from commit 8336061096c259f5c3c93f869ff51bf4daab3fdc) --- source4/torture/rpc/handles.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/source4/torture/rpc/handles.c b/source4/torture/rpc/handles.c index 3fdce56..5c08a5f 100644 --- a/source4/torture/rpc/handles.c +++ b/source4/torture/rpc/handles.c @@ -471,6 +471,11 @@ static bool test_handles_mixed_shared(struct torture_context *torture) torture_assert_ntstatus_equal(torture, status, NT_STATUS_UNSUCCESSFUL, "opening lsa pipe4"); + /* + * We use ~assoc_group_id instead of p1->assoc_group_id, because + * this way we are less likely to use an id which is already in use. + */ + assoc_group_id = ~assoc_group_id; torture_comment(torture, "connect samr pipe5 with assoc_group_id[0x%08X]- should fail\n", ++assoc_group_id); status = torture_rpc_connection_transport(torture, &p5, &ndr_table_samr, transport, -- 1.7.7