Fix bug 6829 - smbclient does not show special characters properly.
authorJeremy Allison <jra@samba.org>
Thu, 22 Oct 2009 22:06:38 +0000 (15:06 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 22 Oct 2009 22:06:38 +0000 (15:06 -0700)
All successful calls to cli_session_setup() *must* be followed by
calls to cli_init_creds() to stash the credentials we successfully
connected with. There were 2 codepaths where this was missing. This
caused smbclient to be unable to open the \srvsvc pipe to do an RPC
netserverenum, and cause it to fall back to a RAP netserverenum,
which uses DOS codepage conversion rather than the full UCS2 of
RPC, so the returned characters were not correct (unless the DOS
codepage was set correctly). Phew. That was fun to track down :-).
Jeremy.

source3/libsmb/clidfs.c
source3/libsmb/libsmb_server.c

index 5e944f1aaad29d6a3a98ff0780cc54275b5b7fa7..53dc6d7984434ddc78effeb4d60ecc2a11a7d667 100644 (file)
@@ -216,6 +216,15 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                        return NULL;
                }
                d_printf("Anonymous login successful\n");
+               status = cli_init_creds(c, "", lp_workgroup(), "");
+       } else {
+               status = cli_init_creds(c, username, lp_workgroup(), password);
+       }
+
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(10,("cli_init_creds() failed: %s\n", nt_errstr(status)));
+               cli_shutdown(c);
+               return NULL;
        }
 
        if ( show_sessetup ) {
index 60849c812fe6130000bf66b6c468ec238ca758f3..18b12a1a9b6295e7510d862932f5c969166917cf 100644 (file)
@@ -498,6 +498,17 @@ again:
                         errno = EPERM;
                         return NULL;
                 }
+               status = cli_init_creds(c, username_used,
+                               *pp_workgroup, *pp_password);
+       } else {
+               status = cli_init_creds(c, username_used,
+                               *pp_workgroup, *pp_password);
+       }
+
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               cli_shutdown(c);
+               return NULL;
        }
 
        DEBUG(4,(" session setup ok\n"));