summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/cliconnect.c4
-rw-r--r--source4/libcli/nmblib.c29
-rw-r--r--source4/libcli/raw/clitree.c12
3 files changed, 37 insertions, 8 deletions
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index 8753f26b5f..14f7d5a1b3 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -23,7 +23,7 @@
/*
wrapper around smbcli_sock_connect()
*/
-BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server, struct in_addr *ip)
+BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server)
{
struct smbcli_socket *sock;
@@ -163,7 +163,7 @@ NTSTATUS smbcli_full_connection(struct smbcli_state **ret_cli,
}
status = smbcli_tree_full_connection(&tree, myname, host, 0, sharename, devtype,
- username, domain, password);
+ username, domain, password);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
diff --git a/source4/libcli/nmblib.c b/source4/libcli/nmblib.c
index e05eb7966e..5eeec48003 100644
--- a/source4/libcli/nmblib.c
+++ b/source4/libcli/nmblib.c
@@ -1285,3 +1285,32 @@ int name_len(char *s1)
return(len);
} /* name_len */
+
+
+/*
+ choose a name to use when calling a server in a NBT session request.
+ we use heuristics to see if the name we have been given is a IP
+ address, or a too-long name. If it is then use *SMBSERVER, or a
+ truncated name
+*/
+void choose_called_name(struct nmb_name *n, const char *name, int type)
+{
+ if (is_ipaddress(name)) {
+ make_nmb_name(n, "*SMBSERVER", type);
+ return;
+ }
+ if (strlen(name) > 16) {
+ const char *p = strchr(name, '.');
+ char name2[17];
+ if (p - name > 16) {
+ make_nmb_name(n, "*SMBSERVER", type);
+ return;
+ }
+ strlcpy(name2, name, 1+(p-name));
+ make_nmb_name(n, name2, type);
+ return;
+ }
+
+ /* looks OK */
+ make_nmb_name(n, name, type);
+}
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index b9d572fd56..97c0910451 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -173,11 +173,11 @@ NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree)
parameters
*/
NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
- const char *my_name,
- const char *dest_host, int port,
- const char *service, const char *service_type,
- const char *user, const char *domain,
- const char *password)
+ const char *my_name,
+ const char *dest_host, int port,
+ const char *service, const char *service_type,
+ const char *user, const char *domain,
+ const char *password)
{
struct smbcli_socket *sock;
struct smbcli_transport *transport;
@@ -212,7 +212,7 @@ NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree,
/* send a NBT session request, if applicable */
make_nmb_name(&calling, my_name, 0x0);
- make_nmb_name(&called, dest_host, 0x20);
+ choose_called_name(&called, dest_host, 0x20);
if (!smbcli_transport_connect(transport, &calling, &called)) {
smbcli_transport_close(transport);