]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb: pass struct smb_transports to cli_full_connection_creds_send()
authorStefan Metzmacher <metze@samba.org>
Sun, 6 Apr 2025 17:05:19 +0000 (19:05 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:29 +0000 (10:17 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/libsmb/cliconnect.c
source3/libsmb/proto.h
source3/libsmb/pylibsmb.c

index 551b91de3df40ce666f08b4250271a4ea4dfdab7..cea373bad7500bf7e6f9108ef38254bff1e4e1c8 100644 (file)
@@ -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) {
index f7903458a9a3bd4d0263ed423559388aae9844bb..959ef0819c5ce5508fcb16b76a566c9fdf9071ca 100644 (file)
@@ -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);
index 958fcfd26d8bd2c3bcf1a1dc43748bb38e1d6a26..187b816d000a3ba5186deea6312e815b63886d0f 100644 (file)
@@ -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)) {