summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/cliconnect.c8
-rw-r--r--source4/libcli/nbt/nameregister.c2
-rw-r--r--source4/libcli/raw/clisocket.c36
-rw-r--r--source4/libcli/raw/clitree.c4
-rw-r--r--source4/libcli/smb2/connect.c5
-rw-r--r--source4/libcli/smb_composite/connect.c3
-rw-r--r--source4/libcli/smb_composite/fetchfile.c2
-rw-r--r--source4/libcli/smb_composite/fsinfo.c2
-rw-r--r--source4/libcli/smb_composite/smb_composite.h6
9 files changed, 29 insertions, 39 deletions
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index a170024def..7ec914e831 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -31,12 +31,12 @@
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;
diff --git a/source4/libcli/nbt/nameregister.c b/source4/libcli/nbt/nameregister.c
index 3d7ab7f72f..6667564664 100644
--- a/source4/libcli/nbt/nameregister.c
+++ b/source4/libcli/nbt/nameregister.c
@@ -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;
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index c09104e256..9732ab1638 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -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)) {
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index 54f8ac95a4..890d5470da 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -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;
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index 8b75e125b0..4d250fdded 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -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);
}
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index 1a8262c76a..fafd3b0173 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -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);
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index 2dbaff5a66..a4f73ffd70 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -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;
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index faf3723539..f37213e2f9 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -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;
diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h
index 617daaf442..a3188c4fe2 100644
--- a/source4/libcli/smb_composite/smb_composite.h
+++ b/source4/libcli/smb_composite/smb_composite.h
@@ -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;