From 608c737cdf45ff2b6e61de97f6f19dde8fea21d2 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 13 Feb 2004 16:55:25 +0000 Subject: [PATCH] Apply the multiple login stuff to smbclient ... (This used to be commit 83213742dcd61ff4d30954158a5523ee0bdd850d) --- source3/client/client.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/source3/client/client.c b/source3/client/client.c index fdc6d0d4e19..d4ad5fa1fe2 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2069,6 +2069,61 @@ static BOOL list_servers(const char *wk_grp) return True; } +/**************************************************************************** + Print or set current VUID +****************************************************************************/ + +static int cmd_vuid(void) +{ + fstring buf; + + if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) { + d_printf("Current VUID is %d\n", cli->vuid); + return 0; + } + + cli->vuid = atoi(buf); + return 0; +} + +/**************************************************************************** + Setup a new VUID, by issuing a session setup +****************************************************************************/ + +static int cmd_logon(void) +{ + pstring l_username, l_password; + fstring buf,buf2; + + if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) { + d_printf("logon []\n"); + return 0; + } + + pstrcpy(l_username, buf); + + if (!next_token_nr(NULL,buf2,NULL,sizeof(buf))) { + char *pass = getpass("Password: "); + if (pass) { + pstrcpy(l_password, pass); + got_pass = 1; + } + } else { + pstrcpy(l_password, buf2); + } + + if (!cli_session_setup(cli, l_username, + l_password, strlen(l_password), + l_password, strlen(l_password), + lp_workgroup())) { + d_printf("session setup failed: %s\n", cli_errstr(cli)); + return -1; + } + + d_printf("Current VUID is %d\n", cli->vuid); + return 0; +} + /* Some constants for completing filename arguments */ #define COMPL_NONE 0 /* No completions */ @@ -2134,6 +2189,8 @@ static struct {"tar",cmd_tar,"tar [IXFqbgNan] current directory to/from ",{COMPL_NONE,COMPL_NONE}}, {"tarmode",cmd_tarmode," tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}}, {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}}, + {"vuid",cmd_vuid,"change current vuid",{COMPL_NONE,COMPL_NONE}}, + {"logon",cmd_logon,"establish new logon",{COMPL_NONE,COMPL_NONE}}, /* Yes, this must be here, see crh's comment above. */ {"!",NULL,"run a shell command on the local system",{COMPL_NONE,COMPL_NONE}}, @@ -2615,7 +2672,6 @@ static struct cli_state *do_connect(const char *server, const char *share) DEBUG(1,("OS=[%s] Server=[%s]\n", c->server_os,c->server_type)); } - DEBUG(4,(" session setup ok\n")); if (!cli_send_tconX(c, sharename, "?????", -- 2.11.4.GIT