From: Stefan Metzmacher Date: Sun, 6 Apr 2025 17:05:19 +0000 (+0200) Subject: s3:libsmb: pass struct smb_transports to cli_full_connection_creds_send() X-Git-Tag: tevent-0.17.0~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef21ac394d7d03670f4ca180afbda1f6e660abdf;p=thirdparty%2Fsamba.git s3:libsmb: pass struct smb_transports to cli_full_connection_creds_send() Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 551b91de3df..cea373bad75 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -3315,7 +3315,8 @@ static void cli_full_connection_creds_tcon_done(struct tevent_req *subreq); struct tevent_req *cli_full_connection_creds_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *my_name, const char *dest_host, - const struct sockaddr_storage *dest_ss, int port, + const struct sockaddr_storage *dest_ss, + const struct smb_transports *transports, const char *service, const char *service_type, struct cli_credentials *creds, int flags, @@ -3339,7 +3340,7 @@ struct tevent_req *cli_full_connection_creds_send( state->service_type = service_type; state->creds = creds; state->flags = flags; - state->transports = smbsock_transports_from_port(port); + state->transports = *transports; if (flags & CLI_FULL_CONNECTION_IPC) { signing_state = cli_credentials_get_smb_ipc_signing(creds); @@ -3687,13 +3688,14 @@ NTSTATUS cli_full_connection_creds(TALLOC_CTX *mem_ctx, struct tevent_context *ev; struct tevent_req *req; NTSTATUS status = NT_STATUS_NO_MEMORY; + struct smb_transports ts = smbsock_transports_from_port(port); ev = samba_tevent_context_init(mem_ctx); if (ev == NULL) { goto fail; } req = cli_full_connection_creds_send( - ev, ev, my_name, dest_host, dest_ss, port, service, + ev, ev, my_name, dest_host, dest_ss, &ts, service, service_type, creds, flags, NULL); if (req == NULL) { diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index f7903458a9a..959ef0819c5 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -107,11 +107,13 @@ struct smb2_negotiate_contexts; struct tevent_req *cli_full_connection_creds_send( TALLOC_CTX *mem_ctx, struct tevent_context *ev, const char *my_name, const char *dest_host, - const struct sockaddr_storage *dest_ss, int port, + const struct sockaddr_storage *dest_ss, + const struct smb_transports *transports, const char *service, const char *service_type, struct cli_credentials *creds, int flags, - struct smb2_negotiate_contexts *negotiate_contexts); + struct smb2_negotiate_contexts *negotiate_contexts) + NONNULL(2) NONNULL(6); NTSTATUS cli_full_connection_creds_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct cli_state **output_cli); diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 958fcfd26d8..187b816d000 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -49,6 +49,7 @@ c = libsmb.Conn("127.0.0.1", #include "includes.h" #include "python/py3compat.h" #include "python/modules.h" +#include "param/pyparam.h" #include "libcli/smb/smbXcli_base.h" #include "libcli/smb/smb2_negotiate_context.h" #include "libcli/smb/reparse.h" @@ -549,6 +550,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args, PyObject *creds = NULL; struct cli_credentials *cli_creds; PyObject *py_lp = Py_None; + struct loadparm_context *lp_ctx = NULL; PyObject *py_multi_threaded = Py_False; bool multi_threaded = false; PyObject *py_force_smb1 = Py_False; @@ -557,6 +559,7 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args, PyObject *py_posix = Py_False; PyObject *py_negotiate_contexts = NULL; struct smb2_negotiate_contexts *negotiate_contexts = NULL; + struct smb_transports ts = { .num_transports = 0, }; bool use_ipc = false; bool request_posix = false; struct tevent_req *req; @@ -655,8 +658,17 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args, cli_creds = PyCredentials_AsCliCredentials(creds); } + lp_ctx = lpcfg_from_py_object(frame, py_lp); + if (lp_ctx == NULL) { + TALLOC_FREE(frame); + return -1; + } + + ts = smb_transports_parse("client smb transports", + lpcfg_client_smb_transports(lp_ctx)); + req = cli_full_connection_creds_send( - frame, self->ev, "myname", host, NULL, 0, share, "?????", + frame, self->ev, "myname", host, NULL, &ts, share, "?????", cli_creds, flags, negotiate_contexts); if (!py_tevent_req_wait_exc(self, req)) {