Fix a bug in smbclient not sending the correct called name
authorVolker Lendecke <vl@samba.org>
Sun, 12 Apr 2009 10:52:42 +0000 (12:52 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 12 Apr 2009 12:51:15 +0000 (14:51 +0200)
Jeremy, I think the ability to say

smbclient //foo/bar -I <ip-address> -p 139

making the called name to "foo" got lost with 3d2d0203. Was this removed
deliberately? If so, please revert this patch. If not, please merge
appropriately.

Thanks,

Volker

source3/libsmb/clidfs.c

index 430807eb7f319db765cc2449aec568e355b697de..98b96cfc566652f34d2ef1e3e5c0a8f546651fb1 100644 (file)
@@ -94,6 +94,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
 {
        struct cli_state *c = NULL;
        struct nmb_name called, calling;
+       const char *called_str;
        const char *server_n;
        struct sockaddr_storage ss;
        char *servicename;
@@ -111,6 +112,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        sharename = servicename;
        if (*sharename == '\\') {
                sharename += 2;
+               called_str = sharename;
                if (server == NULL) {
                        server = sharename;
                }
@@ -120,6 +122,8 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                }
                *sharename = 0;
                sharename++;
+       } else {
+               called_str = server;
        }
 
        server_n = server;
@@ -127,7 +131,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        zero_sockaddr(&ss);
 
        make_nmb_name(&calling, global_myname(), 0x0);
-       make_nmb_name(&called , server, name_type);
+       make_nmb_name(&called , called_str, name_type);
 
  again:
        zero_sockaddr(&ss);