s4:torture: let smb2.session.bind_negative_* also test without session keys
authorStefan Metzmacher <metze@samba.org>
Thu, 10 Jun 2021 16:03:15 +0000 (16:03 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 15 Jul 2021 00:06:31 +0000 (00:06 +0000)
This checks the result of a 2nd session setup without the BIND flags
and also without signing being already enabled.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/smb2.session [new file with mode: 0644]
source4/torture/smb2/session.c

diff --git a/selftest/knownfail.d/smb2.session b/selftest/knownfail.d/smb2.session
new file mode 100644 (file)
index 0000000..3b14f0c
--- /dev/null
@@ -0,0 +1,11 @@
+^samba3.smb2.session.*bind_negative_smb3encGtoC
+^samba3.smb2.session.*ntlm.bind_negative_smb202.ad_dc
+^samba3.smb2.session.*ntlm.bind_negative_smb210.ad_dc
+^samba3.smb2.session.*ntlm.bind_negative_smb2to3.ad_dc
+^samba3.smb2.session.*ntlm.bind_negative_smb3to2.ad_dc
+^samba3.smb2.session.*ntlm.bind_negative_smb3to3.ad_dc
+^samba3.smb2.session.*krb5.bind_negative_smb202.ad_dc
+^samba3.smb2.session.*krb5.bind_negative_smb210.ad_dc
+^samba3.smb2.session.*krb5.bind_negative_smb2to3.ad_dc
+^samba3.smb2.session.*krb5.bind_negative_smb3to2.ad_dc
+^samba3.smb2.session.*krb5.bind_negative_smb3to3.ad_dc
index cac0f76acce18d05f94689e2496ea09166950900..8698e8b386616e5fe710237ff4184b641af377a1 100644 (file)
@@ -2514,6 +2514,8 @@ static bool test_session_bind_negative_smbXtoX(struct torture_context *tctx,
        struct smb2_tree *tree2_0 = NULL;
        struct smb2_transport *transport2 = NULL;
        struct smb2_session *session1_2 = NULL;
+       uint64_t session1_id = 0;
+       uint16_t session1_flags = 0;
 
        status = smb2_connect(tctx,
                              host,
@@ -2530,6 +2532,8 @@ static bool test_session_bind_negative_smbXtoX(struct torture_context *tctx,
        torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
                                        "smb2_connect options1 failed");
        session1_1 = tree1->session;
+       session1_id = smb2cli_session_current_id(session1_1->smbXcli);
+       session1_flags = smb2cli_session_get_flags(session1_1->smbXcli);
 
        /* Add some random component to the file name. */
        snprintf(fname, sizeof(fname), "%s_%s.dat",
@@ -2611,6 +2615,25 @@ static bool test_session_bind_negative_smbXtoX(struct torture_context *tctx,
                                           "smb2_session_setup_spnego failed");
        TALLOC_FREE(session1_2);
 
+       /*
+        * ... and we should also check the status without any existing
+        * session keys.
+        */
+       session1_2 = smb2_session_init(transport2,
+                                      lpcfg_gensec_settings(tctx, tctx->lp_ctx),
+                                      tree2_0);
+       torture_assert(tctx, session1_2 != NULL, "smb2_session_channel failed");
+       talloc_steal(tree2_0->session, transport2);
+       smb2cli_session_set_id_and_flags(session1_2->smbXcli,
+                                        session1_id, session1_flags);
+
+       status = smb2_session_setup_spnego(session1_2,
+                                          credentials,
+                                          0 /* previous_session_id */);
+       torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_USER_SESSION_DELETED, ret, done,
+                                          "smb2_session_setup_spnego failed");
+       TALLOC_FREE(session1_2);
+
        /* Check the initial session is still alive */
        ZERO_STRUCT(qfinfo1);
        qfinfo1.generic.level = RAW_FILEINFO_POSITION_INFORMATION;