]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb: pass struct smb_transports to cli_full_connection_creds()
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>
18 files changed:
examples/fuse/smb2mount.c
examples/winexe/winexe.c
source3/libnet/libnet_join.c
source3/libsmb/cliconnect.c
source3/libsmb/libsmb_server.c
source3/libsmb/proto.h
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/rpcclient/cmd_spoolss.c
source3/rpcclient/rpcclient.c
source3/torture/locktest2.c
source3/torture/torture.c
source3/utils/mdsearch.c
source3/utils/net_ads.c
source3/utils/net_util.c
source3/utils/netlookup.c
source3/utils/smbcacls.c
source3/utils/smbcquotas.c
source3/utils/wspsearch.c

index 69c14af9df1726a1415950e20cb4135099fe699a..82a2f15bda043075425304650d4e7bec79c95915 100644 (file)
@@ -33,13 +33,14 @@ static struct cli_state *connect_one(struct cli_credentials *creds,
        struct cli_state *c = NULL;
        NTSTATUS nt_status;
        uint32_t flags = 0;
+       struct smb_transports ts = smbsock_transports_from_port(port);
 
        nt_status = cli_full_connection_creds(talloc_tos(),
                                              &c,
                                              lp_netbios_name(),
                                              server,
                                              NULL,
-                                             port,
+                                             &ts,
                                              share,
                                              "?????",
                                              creds,
index 774d07a14d08412f54d738ff91f64174cb4579ef..3ea42a87f2d312a30c0da6387779ba7f3fd13936 100644 (file)
@@ -293,6 +293,7 @@ static NTSTATUS winexe_svc_upload(
        uint16_t fnum = 0xffff;
        NTSTATUS status;
        const DATA_BLOB *binary = NULL;
+       struct smb_transports ts = smbsock_transports_from_port(port);
 
        status = cli_full_connection_creds(
                talloc_tos(),
@@ -300,7 +301,7 @@ static NTSTATUS winexe_svc_upload(
                NULL,
                hostname,
                NULL,
-               port,
+               &ts,
                "ADMIN$",
                "?????",
                credentials,
@@ -1836,6 +1837,7 @@ int main(int argc, char *argv[])
 #else
        const DATA_BLOB *winexesvc64_exe = NULL;
 #endif
+       struct smb_transports ts;
        NTSTATUS status;
        int ret = 1;
        int return_code = 0;
@@ -1857,13 +1859,14 @@ int main(int argc, char *argv[])
                goto done;
        }
 
+       ts = smbsock_transports_from_port(options.port);
        status = cli_full_connection_creds(
                talloc_tos(),
                &cli,
                lp_netbios_name(),
                options.hostname,
                NULL,
-               options.port,
+               &ts,
                "IPC$",
                "IPC",
                options.credentials,
index 5796c68e2e0c0f4265c73bc963b5ecf7685ca88d..439bd2c01a92310dedf9d0008c289d7005fb9d8c 100644 (file)
@@ -1070,13 +1070,17 @@ static NTSTATUS libnet_join_connect_dc_ipc(TALLOC_CTX *mem_ctx,
                                           struct cli_state **cli)
 {
        int flags = CLI_FULL_CONNECTION_IPC;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
        NTSTATUS status;
 
        status = cli_full_connection_creds(mem_ctx,
                                           cli,
                                           NULL,
                                           dc,
-                                          NULL, 0,
+                                          NULL,
+                                          &ts,
                                           "IPC$", "IPC",
                                           creds,
                                           flags);
@@ -1647,6 +1651,9 @@ NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
        NTSTATUS status;
        int flags = CLI_FULL_CONNECTION_IPC;
        const struct sockaddr_storage *remote_sockaddr = NULL;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        if (!dc_name) {
                TALLOC_FREE(frame);
@@ -1680,7 +1687,8 @@ NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
                                           &cli,
                                           NULL,
                                           dc_name,
-                                          NULL, 0,
+                                          NULL,
+                                          &ts,
                                           "IPC$", "IPC",
                                           cli_creds,
                                           flags);
@@ -1698,7 +1706,8 @@ NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
                                                   &cli,
                                                   NULL,
                                                   dc_name,
-                                                  NULL, 0,
+                                                  NULL,
+                                                  &ts,
                                                   "IPC$", "IPC",
                                                   anon_creds,
                                                   flags);
index cea373bad7500bf7e6f9108ef38254bff1e4e1c8..a688982b7d961d5751a36f89a7209e3bac634f67 100644 (file)
@@ -3680,7 +3680,8 @@ NTSTATUS cli_full_connection_creds(TALLOC_CTX *mem_ctx,
                                   struct cli_state **output_cli,
                                   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)
@@ -3688,14 +3689,13 @@ 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, &ts, service,
+               ev, ev, my_name, dest_host, dest_ss, transports, service,
                service_type, creds, flags,
                NULL);
        if (req == NULL) {
@@ -3837,6 +3837,9 @@ static struct cli_state *get_ipc_connect(TALLOC_CTX *mem_ctx,
         struct cli_state *cli;
        NTSTATUS nt_status;
        uint32_t flags = CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        flags |= CLI_FULL_CONNECTION_FORCE_SMB1;
        flags |= CLI_FULL_CONNECTION_IPC;
@@ -3846,7 +3849,7 @@ static struct cli_state *get_ipc_connect(TALLOC_CTX *mem_ctx,
                                              NULL,
                                              server,
                                              server_ss,
-                                             0,
+                                             &ts,
                                              "IPC$",
                                              "IPC",
                                              creds,
index c8ded4e9d911d747965fbe23ee67740afe8e0902..8044539d2137afbf90674a43dac948ed4b2c1d38 100644 (file)
@@ -819,6 +819,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
         NTSTATUS nt_status;
        SMBCSRV *srv=NULL;
        SMBCSRV *ipc_srv=NULL;
+       struct smb_transports ts = smbsock_transports_from_port(port);
 
        /*
         * Use srv->cli->desthost and srv->cli->share instead of
@@ -874,7 +875,7 @@ SMBC_attr_server(TALLOC_CTX *ctx,
                                                      lp_netbios_name(),
                                                      server,
                                                      NULL,
-                                                     0,
+                                                     &ts,
                                                      "IPC$",
                                                      "?????",
                                                      creds,
index 959ef0819c5ce5508fcb16b76a566c9fdf9071ca..078ce7aeee44cdf5187899f4d2e54c99f6eb9c74 100644 (file)
@@ -121,10 +121,12 @@ NTSTATUS cli_full_connection_creds(TALLOC_CTX *mem_ctx,
                                   struct cli_state **output_cli,
                                   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);
+                                  int flags)
+       NONNULL(2) NONNULL(6);
 NTSTATUS cli_raw_tcon(struct cli_state *cli,
                      const char *service, const char *pass, const char *dev,
                      uint16_t *max_xmit, uint16_t *tid);
index 73ab36051d130a859311098d457a9f1ed39523ec..fa82ba41034b300f4c7da0f1a266ecd43581d053 100644 (file)
@@ -2462,6 +2462,9 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct c
        struct sockaddr_storage rm_addr;
        char addr[INET6_ADDRSTRLEN];
        struct cli_credentials *anon_creds = NULL;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        if ( is_zero_addr(client_ss) ) {
                DEBUG(2,("spoolss_connect_to_client: resolving %s\n",
@@ -2496,7 +2499,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct c
                                        lp_netbios_name(),
                                        remote_machine,
                                        &rm_addr,
-                                       0,
+                                       &ts,
                                        "IPC$",
                                        "IPC",
                                        anon_creds,
index 17ba74c333f1008b7d8f2f3e7503d80e6a2d1d9e..8d98fc278097674f8ec4206a6666dcc12d84f8b0 100644 (file)
@@ -3506,6 +3506,9 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
        NTSTATUS nt_status;
        WERROR werror;
        struct cli_credentials *creds = samba_cmdline_get_creds();
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        if ( argc != 3 )  {
                printf("Usage: %s <printer> <server>\n", argv[0]);
@@ -3521,7 +3524,7 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
                                              lp_netbios_name(),
                                              argv[2],
                                              NULL,
-                                             0,
+                                             &ts,
                                              "IPC$",
                                              "IPC",
                                              creds,
index 0082813c9989e4197692dc3e4920e7f52268a53c..f558cc21d39e15fd27100a627b3fdfaa1eab865b 100644 (file)
@@ -1324,13 +1324,15 @@ out_free:
        }
 
        if (transport == NCACN_NP) {
+               struct smb_transports ts = smbsock_transports_from_port(opt_port);
+
                nt_status = cli_full_connection_creds(frame,
                                                      &cli,
                                                      lp_netbios_name(),
                                                      host,
                                                      opt_ipaddr ? &server_ss
                                                                 : NULL,
-                                                     opt_port,
+                                                     &ts,
                                                      "IPC$",
                                                      "IPC",
                                                      creds,
index cb01648aa587fb0e2209582b823814c051139e20..35b40c12d8bb542363842aff98f1a42486eaf97f 100644 (file)
@@ -180,6 +180,9 @@ static struct cli_state *connect_one(char *share)
        static int count;
        NTSTATUS nt_status;
        struct cli_credentials *creds = NULL;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        fstrcpy(server,share+2);
        share = strchr_m(server,'\\');
@@ -220,7 +223,7 @@ static struct cli_state *connect_one(char *share)
                                              myname,
                                              server_n,
                                              NULL,
-                                             0,
+                                             &ts,
                                              share,
                                              "?????",
                                              creds,
index 3a83df17f7c2f9a1290323af92e6b84664eccf3c..f70f5c575b1440e3064928d1b158a8f6caed7ac2 100644 (file)
@@ -68,7 +68,6 @@ fstring host, workgroup, share, password, username, myname;
 struct cli_credentials *torture_creds;
 static const char *sockops="TCP_NODELAY";
 int torture_nprocs=1;
-static int port_to_use=0;
 int torture_numops=100;
 int torture_blocksize=1024*1024;
 static int procnum; /* records process count number when forking */
@@ -352,6 +351,9 @@ static bool torture_open_connection_share(struct cli_state **c,
                                   const char *sharename,
                                   int flags)
 {
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
        NTSTATUS status;
 
        status = cli_full_connection_creds(NULL,
@@ -359,14 +361,14 @@ static bool torture_open_connection_share(struct cli_state **c,
                                           myname,
                                           hostname,
                                           NULL, /* dest_ss */
-                                          port_to_use,
+                                          &ts,
                                           sharename,
                                           "?????",
                                           torture_creds,
                                           flags);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("failed to open share connection: //%s/%s port:%d - %s\n",
-                       hostname, sharename, port_to_use, nt_errstr(status));
+               printf("failed to open share connection: //%s/%s - %s\n",
+                       hostname, sharename, nt_errstr(status));
                return False;
        }
 
@@ -1711,6 +1713,9 @@ static bool run_tcon_devtype_test(int dummy)
 {
        static struct cli_state *cli1 = NULL;
        int flags = CLI_FULL_CONNECTION_FORCE_SMB1;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
        NTSTATUS status;
        bool ret = True;
 
@@ -1719,7 +1724,7 @@ static bool run_tcon_devtype_test(int dummy)
                                           myname,
                                           host,
                                           NULL, /* dest_ss */
-                                          port_to_use,
+                                          &ts,
                                           NULL, /* service */
                                           NULL, /* service_type */
                                           torture_creds,
@@ -16492,7 +16497,6 @@ static void usage(void)
               != EOF) {
                switch (opt) {
                case 'p':
-                       port_to_use = atoi(optarg);
                        lpcfg_set_cmdline(lp_ctx, "client smb transports", optarg);
                        break;
                case 's':
index 99e67d54e0a22cadb007afd1581a73b7a3d4e202..2efcabfca6eced05e18b2c417a6085dfdd52dcc8 100644 (file)
@@ -78,6 +78,7 @@ int main(int argc, char **argv)
                POPT_COMMON_VERSION
                POPT_TABLEEND
        };
+       struct smb_transports ts = { .num_transports = 0, };
 
        smb_init_locale();
 
@@ -135,12 +136,15 @@ int main(int argc, char **argv)
 
        creds = samba_cmdline_get_creds();
 
+       ts = smb_transports_parse("client smb transports",
+                                 lp_client_smb_transports());
+
        status = cli_full_connection_creds(frame,
                                           &cli,
                                           lp_netbios_name(),
                                           server,
                                           NULL,
-                                          0,
+                                          &ts,
                                           "IPC$",
                                           "IPC",
                                           creds,
index 3ef2b41e5a3c61b255fb1af8b0c0a18a86d50c52..6c3ebae2e75d2c3fcf71edf30e39789b79c1bc05 100644 (file)
@@ -2291,6 +2291,9 @@ static int net_ads_printer_publish(struct net_context *c,
        LDAPMessage *res = NULL;
        bool ok;
        int ret = -1;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        if (argc < 1 || c->display_usage) {
                d_printf("%s\n%s",
@@ -2340,7 +2343,7 @@ static int net_ads_printer_publish(struct net_context *c,
                                              lp_netbios_name(),
                                              servername,
                                              &server_ss,
-                                             0,
+                                             &ts,
                                              "IPC$",
                                              "IPC",
                                              c->creds,
index 5039902bc5e98032e99da8725afa94e225d642c9..d637dd02777f696fd7e1635298c2d68d20ecbe30 100644 (file)
@@ -109,6 +109,7 @@ NTSTATUS connect_to_service(struct net_context *c,
                            const char *service_name,
                            const char *service_type)
 {
+       struct smb_transports ts = smbsock_transports_from_port(c->opt_port);
        NTSTATUS nt_status;
        int flags = 0;
 
@@ -121,7 +122,7 @@ NTSTATUS connect_to_service(struct net_context *c,
                                              NULL,
                                              server_name,
                                              server_ss,
-                                             c->opt_port,
+                                             &ts,
                                              service_name,
                                              service_type,
                                              c->creds,
@@ -173,6 +174,7 @@ NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
                                const struct sockaddr_storage *server_ss,
                                const char *server_name)
 {
+       struct smb_transports ts = smbsock_transports_from_port(c->opt_port);
        NTSTATUS nt_status;
        struct cli_credentials *anon_creds = NULL;
 
@@ -187,7 +189,7 @@ NTSTATUS connect_to_ipc_anonymous(struct net_context *c,
                                              c->opt_requester_name,
                                              server_name,
                                              server_ss,
-                                             c->opt_port,
+                                             &ts,
                                              "IPC$",
                                              "IPC",
                                              anon_creds,
index 7efc3a3360f6690062b63654082b518564435668..6b99acca595806ae12b0826df705f8bc45d14241 100644 (file)
@@ -63,6 +63,9 @@ static struct con_struct *create_cs(struct net_context *c,
        NTSTATUS nt_status;
        struct sockaddr_storage loopback_ss;
        struct cli_credentials *anon_creds = NULL;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        *perr = NT_STATUS_OK;
 
@@ -100,7 +103,7 @@ static struct con_struct *create_cs(struct net_context *c,
                                              lp_netbios_name(),
                                              lp_netbios_name(),
                                              &loopback_ss,
-                                             0,
+                                             &ts,
                                              "IPC$",
                                              "IPC",
                                              anon_creds,
index c157e9433fa6ad8dc9526b3a709d5554ed608ac8..f7550e0a834aceb993f82198c086a0f7941d768b 100644 (file)
@@ -845,13 +845,16 @@ static struct cli_state *connect_one(struct cli_credentials *creds,
        struct cli_state *c = NULL;
        NTSTATUS nt_status;
        uint32_t flags = 0;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        nt_status = cli_full_connection_creds(talloc_tos(),
                                              &c,
                                              lp_netbios_name(),
                                              server,
                                              NULL,
-                                             0,
+                                             &ts,
                                              share,
                                              "?????",
                                              creds,
index deb4749bf3b7148bc26cfaf445ed51ba23428e9b..4d0b8f43ae7e1037d8f7739e9b1adbfa549ca467 100644 (file)
@@ -522,13 +522,16 @@ static struct cli_state *connect_one(const char *share)
        struct cli_state *c;
        NTSTATUS nt_status;
        uint32_t flags = 0;
+       struct smb_transports ts =
+               smb_transports_parse("client smb transports",
+                                    lp_client_smb_transports());
 
        nt_status = cli_full_connection_creds(talloc_tos(),
                                              &c,
                                              lp_netbios_name(),
                                              server,
                                              NULL,
-                                             0,
+                                             &ts,
                                              share,
                                              "?????",
                                              samba_cmdline_get_creds(),
index 6cd6150c765a345da34a2362b1d5ea2e4d6810a3..d30fbc428c54f7ba3b91dbabcf512cf367017c77 100644 (file)
@@ -610,6 +610,7 @@ int main(int argc, char **argv)
        struct cli_state *c = NULL;
        uint32_t flags = CLI_FULL_CONNECTION_IPC;
        bool ok;
+       struct smb_transports ts = { .num_transports = 0, };
 
        ok = samba_cmdline_init(frame,
                                SAMBA_CMDLINE_CONFIG_CLIENT,
@@ -720,12 +721,15 @@ int main(int argc, char **argv)
                        talloc_strdup(select_stmt->cols, default_column);
        }
 
+       ts = smb_transports_parse("client smb transports",
+                                 lp_client_smb_transports());
+
        status = cli_full_connection_creds(talloc_tos(),
                                           &c,
                                           lp_netbios_name(),
                                           server,
                                           NULL,
-                                          0,
+                                          &ts,
                                           "IPC$",
                                           "IPC",
                                           samba_cmdline_get_creds(),