]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:libcli/smb2: add hack to test anonymous signing and encryption
authorStefan Metzmacher <metze@samba.org>
Wed, 15 May 2024 08:51:42 +0000 (10:51 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 23 May 2024 12:35:37 +0000 (12:35 +0000)
This will be used in torture tests.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source4/libcli/smb2/session.c
source4/libcli/smb2/smb2.h

index e94512d3d3371ef88502185ec83d23888e0e7051..322a7bd6860aed501cc46a6780a6f19ea3d29ba5 100644 (file)
@@ -385,7 +385,9 @@ static void smb2_session_setup_spnego_both_ready(struct tevent_req *req)
                return;
        }
 
-       if (cli_credentials_is_anonymous(state->credentials)) {
+       if (cli_credentials_is_anonymous(state->credentials) &&
+           !state->session->anonymous_session_key)
+       {
                /*
                 * Windows server does not set the
                 * SMB2_SESSION_FLAG_IS_GUEST nor
@@ -399,10 +401,14 @@ static void smb2_session_setup_spnego_both_ready(struct tevent_req *req)
                return;
        }
 
-       status = gensec_session_key(session->gensec, state,
-                                   &session_key);
-       if (tevent_req_nterror(req, status)) {
-               return;
+       if (state->session->forced_session_key.length != 0) {
+               session_key = state->session->forced_session_key;
+       } else {
+               status = gensec_session_key(session->gensec, state,
+                                           &session_key);
+               if (tevent_req_nterror(req, status)) {
+                       return;
+               }
        }
 
        if (state->session_bind) {
index 88e651a396c696c069139c2787a049b040ebe367..1e2f1859fb4e645774e1da02fbe5d66c351eb9b0 100644 (file)
@@ -128,6 +128,8 @@ struct smb2_session {
        struct gensec_security *gensec;
        struct smbXcli_session *smbXcli;
        bool needs_bind;
+       bool anonymous_session_key;
+       DATA_BLOB forced_session_key;
 };