From: Stefan Metzmacher Date: Tue, 8 Apr 2025 12:20:36 +0000 (+0200) Subject: s3:smbd: store transport_type in smbXsrv_channel_global0 X-Git-Tag: tevent-0.17.0~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10e4aa6a6d25b9e94011847b3a5b454165612ce4;p=thirdparty%2Fsamba.git s3:smbd: store transport_type in smbXsrv_channel_global0 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/librpc/idl/smbXsrv.idl b/source3/librpc/idl/smbXsrv.idl index 9569ba9b0ca..9aaa836cd7a 100644 --- a/source3/librpc/idl/smbXsrv.idl +++ b/source3/librpc/idl/smbXsrv.idl @@ -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 { diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 7ce107ee9fc..fc5184961c6 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -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; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 42f629f22b5..866999b32f1 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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, diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 814be6cdf76..1ad66ecbdba 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -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); diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 745985e5c0e..1ec22d476ff 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -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 diff --git a/source3/smbd/smbXsrv_client.c b/source3/smbd/smbXsrv_client.c index 2e9a1a94cf7..fc79672e9c4 100644 --- a/source3/smbd/smbXsrv_client.c +++ b/source3/smbd/smbXsrv_client.c @@ -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)) { diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c index c074bb851de..a4fa61821c8 100644 --- a/source3/smbd/smbXsrv_session.c +++ b/source3/smbd/smbXsrv_session.c @@ -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,