]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/libcli/smb2: pass lp_ctx to smb2_session_init() and remember debug encryption...
authorRalph Boehme <slow@samba.org>
Fri, 18 Jul 2025 17:27:48 +0000 (19:27 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 22 Jul 2025 14:08:36 +0000 (14:08 +0000)
Not yet used, that comes next.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source4/libcli/smb2/connect.c
source4/libcli/smb2/session.c
source4/libcli/smb2/smb2.h
source4/torture/smb2/bench.c
source4/torture/smb2/secleak.c
source4/torture/smb2/session.c
source4/torture/smb2/util.c

index b1c2b56a3e07bd9291dc4229bef58fede8c553bc..92b3364c6c20f4d8032df667b3da832b8c3ecbd1 100644 (file)
@@ -36,6 +36,7 @@
 struct smb2_connect_state {
        struct tevent_context *ev;
        struct cli_credentials *credentials;
+       struct loadparm_context *lp_ctx;
        bool fallback_to_anonymous;
        uint64_t previous_session_id;
        struct resolve_context *resolve_ctx;
@@ -86,6 +87,7 @@ struct tevent_req *smb2_connect_send(TALLOC_CTX *mem_ctx,
 
        state->ev = ev;
        state->credentials = credentials;
+       state->lp_ctx = lp_ctx;
        state->fallback_to_anonymous = fallback_to_anonymous;
        state->previous_session_id = previous_session_id;
        state->options = *options;
@@ -214,7 +216,10 @@ static void smb2_connect_session_start(struct tevent_req *req)
        struct smb2_transport *transport = state->transport;
        struct tevent_req *subreq = NULL;
 
-       state->session = smb2_session_init(transport, state->gensec_settings, state);
+       state->session = smb2_session_init(transport,
+                                          state->lp_ctx,
+                                          state->gensec_settings,
+                                          state);
        if (tevent_req_nomem(state->session, req)) {
                return;
        }
index 322a7bd6860aed501cc46a6780a6f19ea3d29ba5..3b31bf0b5d164cc71165c41be92c9d08b0f8d483 100644 (file)
 #include "auth/gensec/gensec.h"
 #include "auth/credentials/credentials.h"
 #include "../libcli/smb/smbXcli_base.h"
+#include "lib/param/param.h"
 
 /**
   initialise a smb2_session structure
  */
 struct smb2_session *smb2_session_init(struct smb2_transport *transport,
+                                      struct loadparm_context *lp_ctx,
                                       struct gensec_settings *settings,
                                       TALLOC_CTX *parent_ctx)
 {
@@ -45,6 +47,11 @@ struct smb2_session *smb2_session_init(struct smb2_transport *transport,
                return NULL;
        }
        session->transport = talloc_steal(session, transport);
+       session->debug_encryption = lpcfg_debug_encryption(lp_ctx);
+       session->wireshark_keyfile = lpcfg_parm_string(lp_ctx,
+                                                      NULL,
+                                                      "debug encryption",
+                                                      "wireshark keyfile");
 
        session->smbXcli = smbXcli_session_create(session, transport->conn);
        if (session->smbXcli == NULL) {
index 1e2f1859fb4e645774e1da02fbe5d66c351eb9b0..987b1f6bfcbcbf5ace659dbc02e813bb4cbcd646 100644 (file)
@@ -129,6 +129,8 @@ struct smb2_session {
        struct smbXcli_session *smbXcli;
        bool needs_bind;
        bool anonymous_session_key;
+       bool debug_encryption;
+       const char *wireshark_keyfile;
        DATA_BLOB forced_session_key;
 };
 
index e16409bae18c28a204b3d787dd58ae9bc9069c92..48c7aabea4f83ea2d5d59cc1afe72516343fa4bd 100644 (file)
@@ -1475,6 +1475,7 @@ static void test_smb2_bench_session_setup_loop_do_setup(
        struct test_smb2_bench_session_setup_shared_state *state = loop->state;
 
        loop->session = smb2_session_init(loop->conn->transport,
+                                         state->tctx->lp_ctx,
                                          state->gensec_settings,
                                          loop->conn->transport);
        torture_assert_goto(state->tctx, loop->session != NULL,
index ca709ed2f0f426dfdd1f4075de1e6348675d8fb3..10d4548d107746f362dbb39e5b9fc2b2e987d4c6 100644 (file)
@@ -43,6 +43,7 @@ static bool try_failed_login(struct torture_context *tctx, struct smb2_tree *tre
        bool result = true;
 
        session = smb2_session_init(tree->session->transport,
+                                   tctx->lp_ctx,
                                    lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                    tctx);
        torture_assert(tctx, session, "Session initialization failed");
index f8f4eac511f5faf22a92fc789673f870522d81bb..9e80fb554c575ad8e10673bea09fecc8e74a12cb 100644 (file)
@@ -2451,6 +2451,7 @@ static bool test_session_bind_auth_mismatch(struct torture_context *tctx,
         * are mapped to guest.
         */
        session3_1 = smb2_session_init(transport1,
+                                      tctx->lp_ctx,
                                       lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                       tctx);
        torture_assert(tctx, session3_1 != NULL, "smb2_session_channel failed");
@@ -2805,6 +2806,7 @@ static bool test_session_bind_negative_smbXtoX(struct torture_context *tctx,
         * session keys.
         */
        session1_2 = smb2_session_init(transport2,
+                                      tctx->lp_ctx,
                                       lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                       tree2_0);
        torture_assert(tctx, session1_2 != NULL, "smb2_session_channel failed");
@@ -5772,6 +5774,7 @@ static bool test_session_anon_encryption2(struct torture_context *tctx,
        torture_assert(tctx, ok, "smbXcli_session_is_authenticated(user)");
 
        anon_session = smb2_session_init(transport,
+                                        tctx->lp_ctx,
                                         lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                         tctx);
        torture_assert(tctx, anon_session != NULL, "smb2_session_init(anon)");
@@ -5919,6 +5922,7 @@ static bool test_session_anon_encryption3(struct torture_context *tctx,
        torture_assert(tctx, ok, "smbXcli_session_is_authenticated(user)");
 
        anon_session = smb2_session_init(transport,
+                                        tctx->lp_ctx,
                                         lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                         tctx);
        torture_assert(tctx, anon_session != NULL, "smb2_session_init(anon)");
@@ -6153,6 +6157,7 @@ static bool test_session_anon_signing2(struct torture_context *tctx,
         */
        session_id = smb2cli_session_current_id(anon_session->smbXcli);
        anon_session_nosign = smb2_session_init(transport,
+                                               tctx->lp_ctx,
                                                lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                                tctx);
        torture_assert(tctx, anon_session_nosign != NULL, "smb2_session_init(anon_nosign)");
index 65989db0325da402a5680320bd12b1c3eebddec1..22b11e425b6b09f867a959073a93a3afdfdc973d 100644 (file)
@@ -364,6 +364,7 @@ bool torture_smb2_session_setup(struct torture_context *tctx,
        struct smb2_session *session;
 
        session = smb2_session_init(transport,
+                                   tctx->lp_ctx,
                                    lpcfg_gensec_settings(tctx, tctx->lp_ctx),
                                    mem_ctx);