]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: store transport_type in smbXsrv_channel_global0
authorStefan Metzmacher <metze@samba.org>
Tue, 8 Apr 2025 12:20:36 +0000 (14:20 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:30 +0000 (10:17 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/librpc/idl/smbXsrv.idl
source3/smbd/globals.h
source3/smbd/proto.h
source3/smbd/server.c
source3/smbd/smb2_process.c
source3/smbd/smbXsrv_client.c
source3/smbd/smbXsrv_session.c

index 9569ba9b0cacd3726b06059742f6be5b23212f12..9aaa836cd7af19cb3618a854f98693f26ec26904 100644 (file)
@@ -164,6 +164,7 @@ interface smbXsrv
                NTTIME                                  xconn_connect_time;
                server_id                               dst_server_id;
                NTTIME                                  client_connect_time;
+               uint8                                   transport_type;
                DATA_BLOB                               negotiate_request;
        } smbXsrv_connection_pass0;
 
@@ -229,6 +230,7 @@ interface smbXsrv
                [ignore] smbXsrv_connection             *connection;
                uint16                                  signing_algo;
                uint16                                  encryption_cipher;
+               uint8                                   transport_type;
        } smbXsrv_channel_global0;
 
        typedef struct {
index 7ce107ee9fccfc83d71165892dc20343549459cd..fc5184961c6a3d735d5f70b23a6e582d36d25b31 100644 (file)
@@ -211,6 +211,7 @@ bool smbd_smb2_is_compound(const struct smbd_smb2_request *req);
 bool smbd_smb2_is_last_in_compound(const struct smbd_smb2_request *req);
 
 NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
+                            enum smb_transport_type transport_type,
                             NTTIME now, struct smbXsrv_connection **_xconn);
 
 NTSTATUS reply_smb2002(struct smb_request *req, uint16_t choice);
@@ -345,6 +346,7 @@ struct smbXsrv_connection {
                struct tevent_queue *shutdown_wait_queue;
                int sock;
                struct tevent_fd *fde;
+               enum smb_transport_type type;
 
                struct {
                        bool got_session;
index 42f629f22b58bfaf6722d3fd00955235377fa419..866999b32f1abdd098440179417f7e38341b1849 100644 (file)
@@ -869,7 +869,8 @@ void process_smb(struct smbXsrv_connection *xconn,
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
                  int sock_fd,
-                 bool interactive);
+                 bool interactive,
+                 enum smb_transport_type transport_type);
 bool valid_smb1_header(const uint8_t *inbuf);
 bool init_smb1_request(struct smb_request *req,
                      struct smbd_server_connection *sconn,
index 814be6cdf763e875f46b24e5df7d0e6d89f6cabd..1ad66ecbdbab032e51da1c2ac920d0cc4a252f4f 100644 (file)
@@ -980,6 +980,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
        smb_set_close_on_exec(fd);
 
        if (s->parent->interactive) {
+               enum smb_transport_type transport_type = s->transport.type;
                NTSTATUS status;
 
                status = reinit_after_fork(msg_ctx, ev, true);
@@ -987,7 +988,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
                        exit_server("reinit_after_fork() failed");
                        return;
                }
-               smbd_process(ev, msg_ctx, fd, true);
+               smbd_process(ev, msg_ctx, fd, true, transport_type);
                exit_server_cleanly("end of interactive mode");
                return;
        }
@@ -999,6 +1000,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
 
        pid = fork();
        if (pid == 0) {
+               enum smb_transport_type transport_type = s->transport.type;
                char addrstr[INET6_ADDRSTRLEN];
                NTSTATUS status = NT_STATUS_OK;
 
@@ -1040,7 +1042,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
                print_sockaddr(addrstr, sizeof(addrstr), &caddr.u.ss);
                process_set_title("smbd[%s]", "client [%s]", addrstr);
 
-               smbd_process(ev, msg_ctx, fd, false);
+               smbd_process(ev, msg_ctx, fd, false, transport_type);
         exit:
                exit_server_cleanly("end of child");
                return;
@@ -2347,7 +2349,7 @@ extern void build_options(bool screen);
                /* Stop zombies */
                smbd_setup_sig_chld_handler(parent);
 
-               smbd_process(ev_ctx, msg_ctx, sock, true);
+               smbd_process(ev_ctx, msg_ctx, sock, true, SMB_TRANSPORT_TYPE_TCP);
 
                exit_server_cleanly(NULL);
                return(0);
index 745985e5c0e8451d297e4597794dd69b889bbbad..1ec22d476ff51c30e70eb243db6101010a7a5d41 100644 (file)
@@ -1210,6 +1210,7 @@ static int smbXsrv_connection_destructor(struct smbXsrv_connection *xconn)
 }
 
 NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
+                            enum smb_transport_type transport_type,
                             NTTIME now, struct smbXsrv_connection **_xconn)
 {
        TALLOC_CTX *frame = talloc_stackframe();
@@ -1248,6 +1249,7 @@ NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
        }
 
        xconn->transport.sock = sock_fd;
+       xconn->transport.type = transport_type;
 #if defined(WITH_SMB1SERVER)
        smbd_echo_init(xconn);
 #endif
@@ -1883,7 +1885,8 @@ static void smbd_tevent_trace_callback_profile(enum tevent_trace_point point,
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
                  int sock_fd,
-                 bool interactive)
+                 bool interactive,
+                 enum smb_transport_type transport_type)
 {
        const struct loadparm_substitution *lp_sub =
                loadparm_s3_global_substitution();
@@ -1943,7 +1946,11 @@ void smbd_process(struct tevent_context *ev_ctx,
                smbd_setup_sig_hup_handler(sconn);
        }
 
-       status = smbd_add_connection(client, sock_fd, now, &xconn);
+       status = smbd_add_connection(client,
+                                    sock_fd,
+                                    transport_type,
+                                    now,
+                                    &xconn);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
                /*
                 * send a negative session response "not listening on calling
index 2e9a1a94cf75e4456ea807aa8a3cd268d8a078a2..fc79672e9c43144cf449650516d8268d9ed6e8a0 100644 (file)
@@ -300,6 +300,7 @@ static NTSTATUS smb2srv_client_connection_pass(struct smbd_smb2_request *smb2req
                .xconn_connect_time = smb2req->xconn->client->global->initial_connect_time,
                .dst_server_id = global->server_id,
                .client_connect_time = global->initial_connect_time,
+               .transport_type = smb2req->xconn->transport.type,
        };
 
        reqlen = iov_buflen(smb2req->in.vector, smb2req->in.vector_count);
@@ -1201,6 +1202,7 @@ static void smbXsrv_client_connection_pass_loop(struct tevent_req *subreq)
 
        status = smbd_add_connection(client,
                                     sock_fd,
+                                    pass_info0->transport_type,
                                     pass_info0->xconn_connect_time,
                                     &xconn);
        if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
index c074bb851de0c9f47e27504f60bfb7e20ecaee66..a4fa61821c82f1b8f623f81e166a440974dd31f0 100644 (file)
@@ -1432,6 +1432,7 @@ NTSTATUS smbXsrv_session_add_channel(struct smbXsrv_session *session,
                .channel_id = conn->channel_id,
                .creation_time = now,
                .connection = conn,
+               .transport_type = conn->transport.type,
        };
 
        c->local_address = tsocket_address_string(conn->local_address,