r26409: Pass smb ports along.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 12 Dec 2007 01:15:29 +0000 (02:15 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:49:42 +0000 (05:49 +0100)
(This used to be commit 2833f320de1f1fd39c710ad0a61c3fa1bb1df31f)

40 files changed:
source4/client/cifsdd.c
source4/client/cifsdd.h
source4/client/cifsddio.c
source4/client/client.c
source4/client/smbspool.c
source4/lib/socket/socket_ip.c
source4/libcli/cliconnect.c
source4/libcli/nbt/nameregister.c
source4/libcli/raw/clisocket.c
source4/libcli/raw/clitree.c
source4/libcli/smb2/connect.c
source4/libcli/smb_composite/connect.c
source4/libcli/smb_composite/fetchfile.c
source4/libcli/smb_composite/fsinfo.c
source4/libcli/smb_composite/smb_composite.h
source4/libnet/libnet_join.c
source4/libnet/libnet_site.c
source4/librpc/rpc/dcerpc_connect.c
source4/nbt_server/wins/winsclient.c
source4/nbt_server/wins/winsserver.c
source4/nbt_server/wins/winswack.c
source4/ntvfs/cifs/vfs_cifs.c
source4/scripting/ejs/smbcalls_cli.c
source4/smbd/service_stream.h
source4/torture/basic/base.c
source4/torture/basic/misc.c
source4/torture/gentest.c
source4/torture/locktest.c
source4/torture/locktest2.c
source4/torture/masktest.c
source4/torture/nbt/wins.c
source4/torture/raw/composite.c
source4/torture/raw/lockbench.c
source4/torture/raw/openbench.c
source4/torture/rpc/join.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/schannel.c
source4/torture/unix/unix_info2.c
source4/torture/unix/whoami.c
source4/torture/util_smb.c

index 2ce01a222746a1a7aad9fb40db7e3421b62fb233..08c152c3a5cf01ae591a05ee289de31184be2348 100644 (file)
@@ -351,7 +351,7 @@ static void print_transfer_stats(void)
        }
 }
 
-static struct dd_iohandle * open_file(const char * which)
+static struct dd_iohandle * open_file(const char * which, const char **ports)
 {
        int                     options = 0;
        const char *            path = NULL;
@@ -371,12 +371,12 @@ static struct dd_iohandle * open_file(const char * which)
 
        if (strcmp(which, "if") == 0) {
                path = check_arg_pathname("if");
-               handle = dd_open_path(path, check_arg_numeric("ibs"),
+               handle = dd_open_path(path, ports, check_arg_numeric("ibs"),
                                        options);
        } else if (strcmp(which, "of") == 0) {
                options |= DD_WRITE;
                path = check_arg_pathname("of");
-               handle = dd_open_path(path, check_arg_numeric("obs"),
+               handle = dd_open_path(path, ports, check_arg_numeric("obs"),
                                        options);
        } else {
                SMB_ASSERT(0);
@@ -431,11 +431,11 @@ static int copy_files(struct loadparm_context *lp_ctx)
        DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
                        (unsigned long long)iomax, lp_max_xmit(lp_ctx)));
 
-       if (!(ifile = open_file("if"))) {
+       if (!(ifile = open_file("if", lp_smb_ports(lp_ctx)))) {
                return(FILESYS_EXIT_CODE);
        }
 
-       if (!(ofile = open_file("of"))) {
+       if (!(ofile = open_file("of", lp_smb_ports(lp_ctx)))) {
                return(FILESYS_EXIT_CODE);
        }
 
index 2fe8de6ea3c6b21c1078558be0595c0335bea6f8..994c2091030ea2c786c139c57d304e3f4aa3ef24 100644 (file)
@@ -89,6 +89,7 @@ struct dd_iohandle
 #define DD_OPLOCK              0x00000008
 
 struct dd_iohandle * dd_open_path(const char * path,
+                                 const char **ports,
                                uint64_t io_size, int options);
 bool dd_fill_block(struct dd_iohandle * h, uint8_t * buf,
                uint64_t * buf_size, uint64_t need_size, uint64_t block_size);
index 5cea8cf3055ac2d543dfca4be509e60b169ae015..c30bf53196985ecd54c1580329fd7910cd385738 100644 (file)
@@ -221,7 +221,8 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
 }
 
 static struct smbcli_state * init_smb_session(const char * host,
-                                               const char * share)
+                                             const char **ports,
+                                             const char * share)
 {
        NTSTATUS                ret;
        struct smbcli_state *   cli = NULL;
@@ -229,7 +230,7 @@ static struct smbcli_state * init_smb_session(const char * host,
        /* When we support SMB URLs, we can get different user credentials for
         * each connection, but for now, we just use the same one for both.
         */
-       ret = smbcli_full_connection(NULL, &cli, host, share,
+       ret = smbcli_full_connection(NULL, &cli, host, ports, share,
                         NULL /* devtype */, cmdline_credentials, NULL /* events */);
 
        if (!NT_STATUS_IS_OK(ret)) {
@@ -289,6 +290,7 @@ static int open_smb_file(struct smbcli_state * cli,
 }
 
 static struct dd_iohandle * open_cifs_handle(const char * host,
+                                       const char **ports,
                                        const char * share,
                                        const char * path,
                                        uint64_t io_size,
@@ -312,7 +314,7 @@ static struct dd_iohandle * open_cifs_handle(const char * host,
        smbh->h.io_write = smb_write_func;
        smbh->h.io_seek = smb_seek_func;
 
-       if ((smbh->cli = init_smb_session(host, share)) == NULL) {
+       if ((smbh->cli = init_smb_session(host, ports, share)) == NULL) {
                return(NULL);
        }
 
@@ -328,6 +330,7 @@ static struct dd_iohandle * open_cifs_handle(const char * host,
 /* ------------------------------------------------------------------------- */
 
 struct dd_iohandle * dd_open_path(const char * path,
+                                 const char **ports,
                                uint64_t io_size,
                                int options)
 {
@@ -344,7 +347,7 @@ struct dd_iohandle * dd_open_path(const char * path,
                        /* Skip over leading directory separators. */
                        while (*remain == '/' || *remain == '\\') { remain++; }
 
-                       return(open_cifs_handle(host, share, remain,
+                       return(open_cifs_handle(host, ports, share, remain,
                                                io_size, options));
                }
 
index 98b13aba4c8993d4e5bc816244f3f3681c551ea8..748ee2d7cbe25d618a0830e6ee9918fbd4758b9f 100644 (file)
@@ -3017,7 +3017,7 @@ static int process_stdin(struct smbclient_context *ctx)
 return a connection to a server
 *******************************************************/
 static bool do_connect(struct smbclient_context *ctx,
-                                      const char *specified_server, const char *specified_share, struct cli_credentials *cred)
+                      const char *specified_server, const char **ports, const char *specified_share, struct cli_credentials *cred)
 {
        NTSTATUS status;
        char *server, *share;
@@ -3034,7 +3034,7 @@ static bool do_connect(struct smbclient_context *ctx,
 
        ctx->remote_cur_dir = talloc_strdup(ctx, "\\");
        
-       status = smbcli_full_connection(ctx, &ctx->cli, server,
+       status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
                                        share, NULL, cred, 
                                        cli_credentials_get_event_context(cred));
        if (!NT_STATUS_IS_OK(status)) {
@@ -3061,7 +3061,7 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host
 /****************************************************************************
 handle a message operation
 ****************************************************************************/
-static int do_message_op(const char *netbios_name, const char *desthost, const char *destip, int name_type, struct resolve_context *resolve_ctx, int max_xmit, int max_mux)
+static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, int max_xmit, int max_mux)
 {
        struct nbt_name called, calling;
        const char *server_name;
@@ -3073,7 +3073,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
 
        server_name = destip ? destip : desthost;
 
-       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, resolve_ctx, max_xmit, max_mux)) {
+       if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, max_xmit, max_mux)) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
@@ -3221,10 +3221,10 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
        }
 
        if (message) {
-               return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), lp_max_xmit(cmdline_lp_ctx), lp_maxmux(cmdline_lp_ctx));
+               return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), lp_max_xmit(cmdline_lp_ctx), lp_maxmux(cmdline_lp_ctx));
        }
        
-       if (!do_connect(ctx, desthost, service, cmdline_credentials))
+       if (!do_connect(ctx, desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials))
                return 1;
 
        if (base_directory) 
index 57050acab8c1630fc1805211bedf4b9fb828cc32..614e50bb0bf118f3ef2eb297f2f0273e90cd65b5 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 static void            list_devices(void);
-static struct smbcli_state     *smb_connect(const char *, const char *, const char *, const char *, const char *);
+static struct smbcli_state     *smb_connect(const char *, const char *, const char **, const char *, const char *, const char *);
 static int             smb_print(struct smbcli_state *, char *, FILE *);
 
 
@@ -189,7 +189,7 @@ static int          smb_print(struct smbcli_state *, char *, FILE *);
 
   do
   {
-    if ((cli = smb_connect(workgroup, server, printer, username, password)) == NULL)
+    if ((cli = smb_connect(workgroup, server, lp_smb_ports(lp_ctx), printer, username, password)) == NULL)
     {
       if (getenv("CLASS") == NULL)
       {
@@ -255,6 +255,7 @@ list_devices(void)
 static struct smbcli_state *           /* O - SMB connection */
 smb_connect(const char *workgroup,             /* I - Workgroup */
             const char *server,                /* I - Server */
+           const char **ports,           /* I - Ports */
             const char *share,         /* I - Printer */
             const char *username,              /* I - Username */
             const char *password)              /* I - Password */
@@ -269,7 +270,7 @@ smb_connect(const char *workgroup,          /* I - Workgroup */
 
   myname = get_myname();  
        
-  nt_status = smbcli_full_connection(NULL, &c, myname, server, 0, share, NULL,
+  nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share, NULL,
                                     username, workgroup, password, NULL);
   
   free(myname);
index e3676ad71a789d56c8d7d08b96d8d9635c80aedb..e61b6d82fccd3a0ad3bd625ed5b00c42ca439384 100644 (file)
@@ -130,6 +130,8 @@ static NTSTATUS ipv4_connect(struct socket_context *sock,
                if (!srv_ip.s_addr) {
                        return NT_STATUS_BAD_NETWORK_NAME;
                }
+
+               SMB_ASSERT(srv_address->port != 0);
                
                ZERO_STRUCT(srv_addr);
 #ifdef HAVE_SOCK_SIN_LEN
@@ -356,6 +358,8 @@ static NTSTATUS ipv4_sendto(struct socket_context *sock,
        } else {
                struct sockaddr_in srv_addr;
                struct in_addr addr;
+
+               SMB_ASSERT(dest_addr->port != 0);
                
                ZERO_STRUCT(srv_addr);
 #ifdef HAVE_SOCK_SIN_LEN
index a170024def41ee167e3a9b4b579c03e2cf6e1529..7ec914e831946371e83f42d2f1a87798a658e74f 100644 (file)
   wrapper around smbcli_sock_connect()
 */
 bool smbcli_socket_connect(struct smbcli_state *cli, const char *server, 
-                          struct resolve_context *resolve_ctx,
+                          const char **ports, struct resolve_context *resolve_ctx,
                           int max_xmit, int max_mux)
 {
        struct smbcli_socket *sock;
 
-       sock = smbcli_sock_connect_byname(server, 0, NULL, resolve_ctx, 
+       sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx, 
                                          NULL);
 
        if (sock == NULL) return false;
@@ -136,6 +136,7 @@ NTSTATUS smbcli_tconX(struct smbcli_state *cli, const char *sharename,
 NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
                                struct smbcli_state **ret_cli, 
                                const char *host,
+                               const char **ports,
                                const char *sharename,
                                const char *devtype,
                                struct cli_credentials *credentials,
@@ -147,7 +148,8 @@ NTSTATUS smbcli_full_connection(TALLOC_CTX *parent_ctx,
        *ret_cli = NULL;
 
        status = smbcli_tree_full_connection(parent_ctx,
-                                            &tree, host, 0, sharename, devtype,
+                                            &tree, host, ports, 
+                                            sharename, devtype,
                                             credentials, ev);
        if (!NT_STATUS_IS_OK(status)) {
                goto done;
index 3d7ab7f72fb5e520e7c33f4cd9301466c97d29ce..66675646649c14625025911eb639082031679bb4 100644 (file)
@@ -370,7 +370,7 @@ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nb
        state->io = talloc(state, struct nbt_name_register);
        if (state->io == NULL) goto failed;
 
-       state->wins_port = lp_nbt_port(global_loadparm);
+       state->wins_port = io->in.wins_port;
        state->wins_servers = str_list_copy(state, io->in.wins_servers);
        if (state->wins_servers == NULL || 
            state->wins_servers[0] == NULL) goto failed;
index c09104e256b00b2d66c3aa09f086e5786195ba98..9732ab16381a0896523ef456472c92a091f592f9 100644 (file)
@@ -45,12 +45,13 @@ static void smbcli_sock_connect_recv_conn(struct composite_context *ctx);
 
 struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
                                                   const char *host_addr,
-                                                  int port,
+                                                  const char **ports,
                                                   const char *host_name,
                                                   struct event_context *event_ctx)
 {
        struct composite_context *result, *ctx;
        struct sock_connect_state *state;
+       int i;
 
        result = talloc_zero(mem_ctx, struct composite_context);
        if (result == NULL) goto failed;
@@ -72,26 +73,11 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
        state->host_name = talloc_strdup(state, host_name);
        if (state->host_name == NULL) goto failed;
 
-       if (port == 0) {
-               const char **ports = lp_smb_ports(global_loadparm);
-               int i;
-
-               for (i=0;ports[i];i++) /* noop */ ;
-               if (i == 0) {
-                       DEBUG(3, ("no smb ports defined\n"));
-                       goto failed;
-               }
-               state->num_ports = i;
-               state->ports = talloc_array(state, uint16_t, i);
-               if (state->ports == NULL) goto failed;
-               for (i=0;ports[i];i++) {
-                       state->ports[i] = atoi(ports[i]);
-               }
-       } else {
-               state->ports = talloc_array(state, uint16_t, 1);
-               if (state->ports == NULL) goto failed;
-               state->num_ports = 1;
-               state->ports[0] = port;
+       state->num_ports = str_list_length(ports);
+       state->ports = talloc_array(state, uint16_t, state->num_ports);
+       if (state->ports == NULL) goto failed;
+       for (i=0;ports[i];i++) {
+               state->ports[i] = atoi(ports[i]);
        }
 
        ctx = socket_connect_multi_send(state, host_addr,
@@ -164,13 +150,13 @@ NTSTATUS smbcli_sock_connect_recv(struct composite_context *c,
   sync version of the function
 */
 NTSTATUS smbcli_sock_connect(TALLOC_CTX *mem_ctx,
-                            const char *host_addr, int port,
+                            const char *host_addr, const char **ports,
                             const char *host_name,
                             struct event_context *event_ctx,
                             struct smbcli_socket **result)
 {
        struct composite_context *c =
-               smbcli_sock_connect_send(mem_ctx, host_addr, port, host_name,
+               smbcli_sock_connect_send(mem_ctx, host_addr, ports, host_name,
                                         event_ctx);
        return smbcli_sock_connect_recv(c, mem_ctx, result);
 }
@@ -198,7 +184,7 @@ void smbcli_sock_set_options(struct smbcli_socket *sock, const char *options)
 /****************************************************************************
 resolve a hostname and connect 
 ****************************************************************************/
-struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
+struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
                                                 TALLOC_CTX *mem_ctx,
                                                 struct resolve_context *resolve_ctx,
                                                 struct event_context *event_ctx)
@@ -247,7 +233,7 @@ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, int port,
                return NULL;
        }
 
-       status = smbcli_sock_connect(mem_ctx, address, port, name, event_ctx,
+       status = smbcli_sock_connect(mem_ctx, address, ports, name, event_ctx,
                                     &result);
 
        if (!NT_STATUS_IS_OK(status)) {
index 54f8ac95a43a69feabcb61f9d966668f43d0f602..890d5470da16c88ceceec7e8b9ab3647ed69b94e 100644 (file)
@@ -171,7 +171,7 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
 */
 NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
                                     struct smbcli_tree **ret_tree, 
-                                    const char *dest_host, int port,
+                                    const char *dest_host, const char **dest_ports,
                                     const char *service, const char *service_type,
                                     struct cli_credentials *credentials,
                                     struct event_context *ev)
@@ -184,7 +184,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
        }
 
        io.in.dest_host = dest_host;
-       io.in.port = port;
+       io.in.dest_ports = dest_ports;
        io.in.called_name = strupper_talloc(tmp_ctx, dest_host);
        io.in.service = service;
        io.in.service_type = service_type;
index 8b75e125b0d1473a27fc9e0cfc938c1284663288..4d250fdded47c15b630a1c04463c96b6ee205485 100644 (file)
@@ -147,11 +147,12 @@ static void continue_resolve(struct composite_context *creq)
        struct smb2_connect_state *state = talloc_get_type(c->private_data, 
                                                           struct smb2_connect_state);
        const char *addr;
-       
+       const char *ports[2] = { "445", NULL };
+
        c->status = resolve_name_recv(creq, state, &addr);
        if (!composite_is_ok(c)) return;
 
-       creq = smbcli_sock_connect_send(state, addr, 445, state->host, c->event_ctx);
+       creq = smbcli_sock_connect_send(state, addr, ports, state->host, c->event_ctx);
 
        composite_continue(c, creq, continue_socket, c);
 }
index 1a8262c76a31847d4ece3163c83ee476a4409fce..fafd3b0173c5b99b2ca58d1bcd1a38b9fedb7c45 100644 (file)
@@ -360,7 +360,8 @@ static NTSTATUS connect_resolve(struct composite_context *c,
        status = resolve_name_recv(state->creq, state, &address);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       state->creq = smbcli_sock_connect_send(state, address, io->in.port,
+       state->creq = smbcli_sock_connect_send(state, address, 
+                                              io->in.dest_ports,
                                               io->in.dest_host, c->event_ctx);
        NT_STATUS_HAVE_NO_MEMORY(state->creq);
 
index 2dbaff5a662cca2863bf97836e66b93c63818042..a4f73ffd7015dacca96197b9a30aacf52d537ed7 100644 (file)
@@ -137,7 +137,7 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
        state->io = io;
 
        state->connect->in.dest_host    = io->in.dest_host;
-       state->connect->in.port         = io->in.port;
+       state->connect->in.dest_ports   = io->in.ports;
        state->connect->in.called_name  = io->in.called_name;
        state->connect->in.service      = io->in.service;
        state->connect->in.service_type = io->in.service_type;
index faf372353912939f5cfe1c0327ef7c151729ffc9..f37213e2f9b1c70367e092ae8ad96362eaa4c488 100644 (file)
@@ -143,7 +143,7 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
        if (state->connect == NULL) goto failed;
 
        state->connect->in.dest_host    = io->in.dest_host;
-       state->connect->in.port         = io->in.port;
+       state->connect->in.dest_ports   = io->in.dest_ports;
        state->connect->in.called_name  = io->in.called_name;
        state->connect->in.service      = io->in.service;
        state->connect->in.service_type = io->in.service_type;
index 617daaf442301aa36f6ef49176cb090eeb0107e5..a3188c4fe24e542dcaf1f39472ed5a361067aaec 100644 (file)
@@ -45,7 +45,7 @@ struct smb_composite_loadfile {
 struct smb_composite_fetchfile {
        struct {
                const char *dest_host;
-               int port;
+               const char **ports;
                const char *called_name;
                const char *service;
                const char *service_type;
@@ -84,7 +84,7 @@ struct smb_composite_savefile {
 struct smb_composite_connect {
        struct {
                const char *dest_host;
-               int port;
+               const char **dest_ports;
                const char *called_name;
                const char *service;
                const char *service_type;
@@ -121,7 +121,7 @@ struct smb_composite_sesssetup {
 struct smb_composite_fsinfo {
        struct {
                const char *dest_host;
-               int port;
+               const char **dest_ports;
                const char *called_name;
                const char *service;
                const char *service_type;
index 6d7fcd09adef18ab9de942fac1ca42724ffb3637..8297172a5859be199548df898619b992707e1f56 100644 (file)
@@ -390,7 +390,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        r->out.account_guid = samdb_result_guid(res->msgs[0], "objectGUID");
 
        if (r->in.acct_type == ACB_SVRTRUST) {
-               status = libnet_JoinSite(remote_ldb, r);
+               status = libnet_JoinSite(ctx, remote_ldb, r);
        }
        talloc_free(tmp_ctx);
 
index ab51b5cf3be90a0fe4fe4f25866268b9f1ca1d1f..0e498e85234968c4055bf8c3e58b6f1a58d0c0a5 100644 (file)
@@ -116,7 +116,8 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
  * 2. Add entry CN=<netbios name>,CN=Servers,CN=<site name>,CN=Sites,CN=Configuration,<domain dn>.
  * TODO: 3.) use DsAddEntry() to create CN=NTDS Settings,CN=<netbios name>,CN=Servers,CN=<site name>,...
  */
-NTSTATUS libnet_JoinSite(struct ldb_context *remote_ldb,
+NTSTATUS libnet_JoinSite(struct libnet_context *ctx, 
+                        struct ldb_context *remote_ldb,
                         struct libnet_JoinDomain *libnet_r)
 {
        NTSTATUS status;
@@ -147,7 +148,7 @@ NTSTATUS libnet_JoinSite(struct ldb_context *remote_ldb,
        }
 
        make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
-       status = resolve_name(lp_resolve_context(global_loadparm), &name, r, &dest_addr, NULL);
+       status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                libnet_r->out.error_string = NULL;
                talloc_free(tmp_ctx);
index a7c26f2f933190779864842aa2519c71f2a8e6a0..8fd783fb83a65fff8a948446c5e549bd728978eb 100644 (file)
@@ -111,7 +111,7 @@ static struct composite_context *dcerpc_pipe_connect_ncacn_np_smb_send(TALLOC_CT
        /* prepare smb connection parameters: we're connecting to IPC$ share on
           remote rpc server */
        conn->in.dest_host              = s->io.binding->host;
-       conn->in.port                   = 0;
+       conn->in.dest_ports                  = lp_smb_ports(global_loadparm);
        if (s->io.binding->target_hostname == NULL)
                conn->in.called_name = "*SMBSERVER"; /* FIXME: This is invalid */
        else
index 001ad58f62d559011c823a1ae9f9278f9252e742..1d07f4a60aaff28ebe12a8591f3b7d5a8f270a14 100644 (file)
@@ -237,6 +237,7 @@ void nbtd_winsclient_register(struct nbtd_iface_name *iname)
 
        /* setup a wins name register request */
        io.in.name            = iname->name;
+       io.in.wins_port       = lp_nbt_port(iname->iface->nbtsrv->task->lp_ctx);
        io.in.wins_servers    = lp_wins_server_list(iname->iface->nbtsrv->task->lp_ctx);
        io.in.addresses       = nbtd_address_list(iface, iname);
        io.in.nb_flags        = iname->nb_flags;
index 693e66707850cac837b202049193a47d7eec6024..f116c458981723e391d6d4d78068e75d1d06afa9 100644 (file)
@@ -378,7 +378,7 @@ static void wins_register_wack(struct nbt_name_socket *nbtsock,
        if (talloc_reference(s, src) == NULL) goto failed;
 
        s->io.in.nbtd_server    = iface->nbtsrv;
-       s->io.in.nbtd_port      = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
+       s->io.in.nbt_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
        s->io.in.event_ctx      = iface->nbtsrv->task->event_ctx;
        s->io.in.name           = rec->name;
        s->io.in.num_addresses  = winsdb_addr_list_length(rec->addresses);
index 6dc90af3171353587e9b48698e1abda111749ec0..3ffa2df79c09d0d69d9d0d39204f1336b1bd7646 100644 (file)
@@ -27,6 +27,7 @@
 #include "system/time.h"
 #include "libcli/composite/composite.h"
 #include "param/param.h"
+#include "smbd/service_task.h"
 
 struct wins_challenge_state {
        struct wins_challenge_io *io;
@@ -162,7 +163,7 @@ static void wins_release_demand_handler(struct nbt_name_request *req)
                if (state->current_address < state->io->in.num_addresses) {
                        struct nbtd_interface *iface;
 
-                       state->release.in.dest_port = lp_nbt_port(global_loadparm);
+                       state->release.in.dest_port = lp_nbt_port(state->io->in.nbtd_server->task->lp_ctx);
                        state->release.in.dest_addr = state->io->in.addresses[state->current_address];
                        state->release.in.address   = state->release.in.dest_addr;
                        state->release.in.timeout   = (state->addresses_left > 1 ? 2 : 1);
index 152a4056c5a56648a72b8d6d7feb21c8312cac14..178e9b01ccc381c1529a3d9212e9123f902153e5 100644 (file)
@@ -194,7 +194,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
 
        /* connect to the server, using the smbd event context */
        io.in.dest_host = host;
-       io.in.port = 0;
+       io.in.dest_ports = lp_smb_ports(ntvfs->ctx->lp_ctx);
        io.in.called_name = host;
        io.in.credentials = credentials;
        io.in.fallback_to_anonymous = false;
index e08a09883383034ac72a2791cc64248879aa972e..a7210eb0fb7eb7954cfed0f2473902596d6508f5 100644 (file)
@@ -437,7 +437,7 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
        /* Do connect */
 
        io.in.dest_host              = hostname;
-       io.in.port                   = 0;
+       io.in.dest_ports             = lp_smb_ports(global_loadparm);
        io.in.called_name            = strupper_talloc(mem_ctx, hostname);
        io.in.service                = sharename;
        io.in.service_type           = "?????";
index 6eb26a42825605f06b44571cbf1fe0825808adcc..04d23a56f26897c87f50d765fcbf3ec94a74dc47 100644 (file)
@@ -48,6 +48,7 @@ struct stream_connection {
 
        struct socket_context *socket;
        struct messaging_context *msg_ctx;
+       struct loadparm_context *lp_ctx;
 
        bool processing;
        const char *terminate;
index 6f02fc4fe5822d5664bda2cd3fbf5eea0ada5d95..cba57ac4130bebc5a6445babd18b9fb586e9ace4 100644 (file)
@@ -51,7 +51,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
                goto failed;
        }
 
-       if (!smbcli_socket_connect(cli, host, lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) {
+       if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) {
                torture_comment(tctx, "Failed to connect with %s\n", host);
                goto failed;
        }
index e9a41e8299995da00ffec7acb8ce938d02610865..0832556b53e7118704fdead5ac85deaa38d28dba 100644 (file)
@@ -815,7 +815,7 @@ static struct composite_context *torture_connect_async(
        torture_comment(tctx, "Open Connection to %s/%s\n",host,share);
        smb->in.dest_host=talloc_strdup(mem_ctx,host);
        smb->in.service=talloc_strdup(mem_ctx,share);
-       smb->in.port=0;
+       smb->in.dest_ports=lp_smb_ports(tctx->lp_ctx);
        smb->in.called_name = strupper_talloc(mem_ctx, host);
        smb->in.service_type=NULL;
        smb->in.credentials=cmdline_credentials;
index 25512b95673375c8e6fdd27e66b8df353d56baad..b257f1dc351348e441af2c5fed1d1dec3f3ccfc7 100644 (file)
@@ -152,7 +152,7 @@ static bool connect_servers_fast(void)
 /***************************************************** 
 connect to the servers
 *******************************************************/
-static bool connect_servers(void)
+static bool connect_servers(struct loadparm_context *lp_ctx)
 {
        int i, j;
 
@@ -185,6 +185,7 @@ static bool connect_servers(void)
 
                        status = smbcli_full_connection(NULL, &servers[i].cli[j],
                                                        servers[i].server_name, 
+                                                       lp_smb_ports(lp_ctx),
                                                        servers[i].share_name, NULL, 
                                                        servers[i].credentials, NULL);
                        if (!NT_STATUS_IS_OK(status)) {
@@ -1927,11 +1928,11 @@ static struct {
   run the test with the current set of op_parms parameters
   return the number of operations that completed successfully
 */
-static int run_test(void)
+static int run_test(struct loadparm_context *lp_ctx)
 {
        int op, i;
 
-       if (!connect_servers()) {
+       if (!connect_servers(lp_ctx)) {
                printf("Failed to connect to servers\n");
                exit(1);
        }
@@ -2008,7 +2009,7 @@ static int run_test(void)
    perform a backtracking analysis of the minimal set of operations
    to generate an error
 */
-static void backtrack_analyze(void)
+static void backtrack_analyze(struct loadparm_context *lp_ctx)
 {
        int chunk, ret;
 
@@ -2029,7 +2030,7 @@ static void backtrack_analyze(void)
                        }
                        printf("Testing %d ops with %d-%d disabled\n", 
                               options.numops, base, max-1);
-                       ret = run_test();
+                       ret = run_test(lp_ctx);
                        printf("Completed %d of %d ops\n", ret, options.numops);
                        for (i=base;i<max; i++) {
                                op_parms[i].disabled = false;
@@ -2061,7 +2062,7 @@ static void backtrack_analyze(void)
        } while (chunk > 0);
 
        printf("Reduced to %d ops\n", options.numops);
-       ret = run_test();
+       ret = run_test(lp_ctx);
        if (ret != options.numops - 1) {
                printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
        }
@@ -2070,7 +2071,7 @@ static void backtrack_analyze(void)
 /* 
    start the main gentest process
 */
-static bool start_gentest(void)
+static bool start_gentest(struct loadparm_context *lp_ctx)
 {
        int op;
        int ret;
@@ -2106,15 +2107,15 @@ static bool start_gentest(void)
                }
        }
 
-       ret = run_test();
+       ret = run_test(lp_ctx);
 
        if (ret != options.numops && options.analyze) {
                options.numops = ret+1;
-               backtrack_analyze();
+               backtrack_analyze(lp_ctx);
        } else if (options.analyze_always) {
-               backtrack_analyze();
+               backtrack_analyze(lp_ctx);
        } else if (options.analyze_continuous) {
-               while (run_test() == options.numops) ;
+               while (run_test(lp_ctx) == options.numops) ;
        }
 
        return ret == options.numops;
@@ -2279,7 +2280,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
 
        printf("seed=%u\n", options.seed);
 
-       ret = start_gentest();
+       ret = start_gentest(lp_ctx);
 
        if (ret) {
                printf("gentest completed - no errors\n");
index 82e9b416b3cb64c12a511ce486e2a1fdd1edde71..9758cd2cf666f14178eceab384138b50a3cd757b 100644 (file)
@@ -153,6 +153,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
                printf("\\\\%s\\%s\n", server, share);
                status = smbcli_full_connection(NULL, &c, 
                                                server, 
+                                               lp_smb_ports(lp_ctx),
                                                share, NULL,
                                                servers[snum], NULL);
                if (!NT_STATUS_IS_OK(status)) {
index 1dfefc15ed88464ddd46e4047f4b19c34f7294bd..db323e139169b38ef988b57ac168414a3ee6c443 100644 (file)
@@ -136,7 +136,7 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
 /***************************************************** 
 return a connection to a server
 *******************************************************/
-static struct smbcli_state *connect_one(char *share)
+static struct smbcli_state *connect_one(char *share, const char **ports)
 {
        struct smbcli_state *c;
        char *server_n;
@@ -163,7 +163,7 @@ static struct smbcli_state *connect_one(char *share)
        slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++);
 
        nt_status = smbcli_full_connection(NULL, 
-                                          &c, myname, server_n, 0, share, NULL,
+                                          &c, myname, server_n, ports, share, NULL,
                                           username, lp_workgroup(), password, NULL);
        if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -179,6 +179,7 @@ static struct smbcli_state *connect_one(char *share)
 static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], 
                      char *nfs[NSERVERS], 
                      int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
+                     const char **ports,
                      char *share1, char *share2)
 {
        int server, conn, f, fstype;
@@ -197,7 +198,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                        smbcli_ulogoff(cli[server][conn]);
                        talloc_free(cli[server][conn]);
                }
-               cli[server][conn] = connect_one(share[server]);
+               cli[server][conn] = connect_one(share[server], ports);
                if (!cli[server][conn]) {
                        DEBUG(0,("Failed to connect to %s\n", share[server]));
                        exit(1);
@@ -343,7 +344,7 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
    we then do random locking ops in tamdem on the 4 fnums from each
    server and ensure that the results match
  */
-static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2)
+static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports)
 {
        struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
        char *nfs[NSERVERS];
@@ -372,7 +373,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                recorded[n].needed = true;
        }
 
-       reconnect(cli, nfs, fnum, share1, share2);
+       reconnect(cli, nfs, fnum, share1, share2, ports);
        open_files(cli, nfs, fnum);
        n = retest(cli, nfs, fnum, numops);
 
@@ -383,7 +384,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
                n1 = n;
 
                close_files(cli, nfs, fnum);
-               reconnect(cli, nfs, fnum, share1, share2);
+               reconnect(cli, nfs, fnum, share1, share2, ports);
                open_files(cli, nfs, fnum);
 
                for (i=0;i<n-1;i++) {
@@ -410,7 +411,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
        }
 
        close_files(cli, nfs, fnum);
-       reconnect(cli, nfs, fnum, share1, share2);
+       reconnect(cli, nfs, fnum, share1, share2, ports);
        open_files(cli, nfs, fnum);
        showall = true;
        n1 = retest(cli, nfs, fnum, n);
@@ -538,7 +539,7 @@ static void usage(void)
        srandom(seed);
 
        locking_init(1);
-       test_locks(share1, share2, nfspath1, nfspath2);
+       test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx));
 
        return(0);
 }
index 63ad6027a1f64ca91ea395e79a1752f0438573f7..4603fd05e4bc774c118e188bc4fede69fa18db50 100644 (file)
@@ -69,7 +69,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
 /***************************************************** 
 return a connection to a server
 *******************************************************/
-static struct smbcli_state *connect_one(char *share)
+static struct smbcli_state *connect_one(char *share, const char **ports)
 {
        struct smbcli_state *c;
        fstring server;
@@ -85,6 +85,7 @@ static struct smbcli_state *connect_one(char *share)
 
        status = smbcli_full_connection(NULL, &c,
                                        server, 
+                                       ports,
                                        share, NULL,
                                        credentials, NULL);
 
@@ -363,7 +364,7 @@ static void usage(void)
        argc -= optind;
        argv += optind;
 
-       cli = connect_one(share);
+       cli = connect_one(share, lp_smb_ports(lp_ctx));
        if (!cli) {
                DEBUG(0,("Failed to connect to %s\n", share));
                exit(1);
index 3107b190757d048fa0389ef61e198bd93e0b2be0..cf115fcd755e0bee43c818dfea513c201ff77597 100644 (file)
@@ -94,6 +94,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
 
        torture_comment(tctx, "register the name\n");
        io.in.name = *name;
+       io.in.wins_port = lp_nbt_port(tctx->lp_ctx);
        io.in.wins_servers = str_list_make(tctx, address, NULL);
        io.in.addresses = str_list_make(tctx, myaddress, NULL);
        io.in.nb_flags = nb_flags;
index 5a663fb565cdea77a04048a8af4c3e5341b0fb58..0367110ddc41d6123a6ad6aeec25c65e04313be9 100644 (file)
@@ -153,7 +153,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct
        }
 
        io2.in.dest_host = torture_setting_string(tctx, "host", NULL);
-       io2.in.port = 0;
+       io2.in.ports = lp_smb_ports(tctx->lp_ctx);
        io2.in.called_name = torture_setting_string(tctx, "host", NULL);
        io2.in.service = torture_setting_string(tctx, "share", NULL);
        io2.in.service_type = "A:";
@@ -341,7 +341,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
        bool ret = true;
 
        io1.in.dest_host = torture_setting_string(tctx, "host", NULL);
-       io1.in.port = 0;
+       io1.in.dest_ports = lp_smb_ports(tctx->lp_ctx);
        io1.in.called_name = torture_setting_string(tctx, "host", NULL);
        io1.in.service = torture_setting_string(tctx, "share", NULL);
        io1.in.service_type = "A:";
index 113634f26436fe3c2b7c8741783398d0711c19a7..744aab66b1d6b4488bf59b5e585dc61e7e4913d8 100644 (file)
@@ -185,7 +185,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
        }
 
        io->in.dest_host    = state->dest_host;
-       io->in.port         = state->dest_port;
+       io->in.dest_ports   = state->dest_port;
        io->in.called_name  = state->called_name;
        io->in.service      = share;
        io->in.service_type = state->service_type;
index 8f9803fa4dbf03b0b0b773c99c51382cc2844ee3..ceb52cdfcf19d4dd0d3d8a2065457dbe2561060d 100644 (file)
@@ -123,7 +123,7 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
        }
 
        io->in.dest_host    = state->dest_host;
-       io->in.port         = state->dest_port;
+       io->in.dest_ports   = state->dest_port;
        io->in.called_name  = state->called_name;
        io->in.service      = share;
        io->in.service_type = state->service_type;
index d973d2d0836f5a436c14c82c0796c4214ea527b8..8ab6ae03ead1a5f84877fdbda3be5e04cbfac489 100644 (file)
@@ -5,6 +5,8 @@
 #include "auth/credentials/credentials.h"
 #include "torture/rpc/rpc.h"
 
+#include "param/param.h"
+
 #define TORTURE_NETBIOS_NAME "smbtorturejoin"
 
 
@@ -29,6 +31,7 @@ bool torture_rpc_join(struct torture_context *torture)
        }
 
        status = smbcli_full_connection(tj, &cli, host,
+                                       lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL,
                                        machine_account,
                                        NULL);
@@ -53,6 +56,7 @@ bool torture_rpc_join(struct torture_context *torture)
        }
 
        status = smbcli_full_connection(tj, &cli, host,
+                                       lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL,
                                        machine_account,
                                        NULL);
index 96ed03fc6f382c246094490f5ed716c9e276e631..496453e1812c13c30ee2c2903425d0b957f99ad1 100644 (file)
@@ -80,6 +80,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
 
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
+                                       lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        NULL);
        if (!NT_STATUS_IS_OK(status)) {
@@ -287,6 +288,7 @@ bool torture_bind_samba3(struct torture_context *torture)
 
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
+                                       lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, cmdline_credentials,
                                        NULL);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1144,6 +1146,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
 
        status = smbcli_full_connection(mem_ctx, &cli,
                                        torture_setting_string(torture, "host", NULL),
+                                       lp_smb_ports(torture->lp_ctx),
                                        "IPC$", NULL, anon_creds, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
@@ -1225,6 +1228,7 @@ static bool test_join3(struct torture_context *tctx,
 
        status = smbcli_full_connection(tctx, &cli,
                                        torture_setting_string(tctx, "host", NULL),
+                                       lp_smb_ports(tctx->lp_ctx),
                                        "IPC$", NULL, smb_creds, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("smbcli_full_connection failed: %s\n",
@@ -1588,6 +1592,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
 
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+               lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, cmdline_credentials, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) smbcli_full_connection failed: %s\n",
@@ -1612,6 +1617,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
 
        status = smbcli_full_connection(
                mem_ctx, &cli, torture_setting_string(torture, "host", NULL),
+               lp_smb_ports(torture->lp_ctx),
                "IPC$", NULL, anon_creds, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("(%s) anon smbcli_full_connection failed: %s\n",
index 6b0cbbf52543f02340f0ae65b77af196ac9411a8..cb9b8be2c95736fe35bbb0caaa938bfd1af42b7c 100644 (file)
@@ -244,7 +244,8 @@ static bool test_schannel(struct torture_context *tctx,
        struct creds_CredentialState *creds;
        struct cli_credentials *credentials;
 
-       join_ctx = torture_join_domain(tctx, talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i), 
+       join_ctx = torture_join_domain(tctx, 
+                                      talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i), 
                                       acct_flags, &credentials);
        torture_assert(tctx, join_ctx != NULL, "Failed to join domain");
 
index 882dc7a084819a55c63d8d85a3b02417cb830f48..d5fe8bc2604d22a31bb60e3750f461e770b10283 100644 (file)
@@ -26,6 +26,7 @@
 #include "torture/basic/proto.h"
 #include "lib/cmdline/popt_common.h"
 #include "auth/credentials/credentials.h"
+#include "param/param.h"
 
 struct unix_info2 {
        uint64_t end_of_file;
@@ -54,8 +55,9 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
 
-       status = smbcli_full_connection(tctx, &cli,
-                                       host, share, NULL,
+       status = smbcli_full_connection(tctx, &cli, host, 
+                                       lp_smb_ports(tctx->lp_ctx),
+                                       share, NULL,
                                        cmdline_credentials, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
index 422e2abcbf4900efec0be59c1745c526147721b3..412a256da7c46e48355bb4477062674c02837751 100644 (file)
@@ -75,8 +75,9 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
        const char *host = torture_setting_string(tctx, "host", NULL);
        const char *share = torture_setting_string(tctx, "share", NULL);
 
-       status = smbcli_full_connection(tctx, &cli,
-                                       host, share, NULL,
+       status = smbcli_full_connection(tctx, &cli, host, 
+                                       lp_smb_ports(tctx->lp_ctx),
+                                       share, NULL,
                                        creds, NULL);
 
        if (!NT_STATUS_IS_OK(status)) {
index 65dfaec1ccdcead2e8b2219194a8b88060fe4099..1168f316793b8e30582ccbf4bcbc38e6c45e07d5 100644 (file)
@@ -474,6 +474,7 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
 
        status = smbcli_full_connection(mem_ctx, c, hostname, 
+                                       lp_smb_ports(tctx->lp_ctx),
                                        sharename, NULL,
                                        cmdline_credentials, ev);
        if (!NT_STATUS_IS_OK(status)) {