From fd0f873a367b133fd41af34dc168bd594ee2928c Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Sun, 15 Jan 2006 06:43:24 +0000 Subject: Cancel a dbclient password prompt if the user presses ctrl-c. Enter still has to be pressed since glibc blocks ctrl-c in getpass() --HG-- extra : convert_revision : 1c8128fba89431f2460dd5914f0614850d529b76 --- cli-auth.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cli-auth.c') diff --git a/cli-auth.c b/cli-auth.c index 6a6d53a..d08de9a 100644 --- a/cli-auth.c +++ b/cli-auth.c @@ -278,3 +278,18 @@ void cli_auth_try() { TRACE(("leave cli_auth_try")) } + +/* A helper for getpass() that exits if the user cancels. The returned + * password is statically allocated by getpass() */ +char* getpass_or_cancel() +{ + char* password = NULL; + + password = getpass("Password: "); + + /* 0x03 is a ctrl-c character in the buffer. */ + if (password == NULL || strchr(password, '\3') != NULL) { + dropbear_close("Interrupted."); + } + return password; +} -- cgit v1.2.3 From 1e03393b6813b8dc77916665d8940475f06acdb2 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Sat, 25 Mar 2006 12:57:37 +0000 Subject: Some cleanups/fixes for various TRACE statements --HG-- extra : convert_revision : 84eb6fedc6df0666f8053b9018bf16635dbfb257 --- cli-auth.c | 2 +- cli-chansession.c | 4 ++-- common-channel.c | 2 +- svr-auth.c | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'cli-auth.c') diff --git a/cli-auth.c b/cli-auth.c index d08de9a..ba4cf6c 100644 --- a/cli-auth.c +++ b/cli-auth.c @@ -236,8 +236,8 @@ void recv_msg_userauth_success() { void cli_auth_try() { - TRACE(("enter cli_auth_try")) int finished = 0; + TRACE(("enter cli_auth_try")) CHECKCLEARTOWRITE(); diff --git a/cli-chansession.c b/cli-chansession.c index 6d358b7..1dad607 100644 --- a/cli-chansession.c +++ b/cli-chansession.c @@ -162,14 +162,14 @@ void cli_tty_cleanup() { static void put_termcodes() { - TRACE(("enter put_termcodes")) - struct termios tio; unsigned int sshcode; const struct TermCode *termcode; unsigned int value; unsigned int mapcode; + TRACE(("enter put_termcodes")) + unsigned int bufpos1, bufpos2; if (tcgetattr(STDIN_FILENO, &tio) == -1) { diff --git a/common-channel.c b/common-channel.c index 68d2b48..0be354d 100644 --- a/common-channel.c +++ b/common-channel.c @@ -236,7 +236,7 @@ static void checkclose(struct Channel *channel) { TRACE(("checkclose: writefd %d, readfd %d, errfd %d, sentclosed %d, recvclosed %d", channel->writefd, channel->readfd, channel->errfd, channel->sentclosed, channel->recvclosed)) - TRACE(("writebuf %d extrabuf %s extrabuf %d", + TRACE(("writebuf size %d extrabuf ptr 0x%x extrabuf size %d", cbuf_getused(channel->writebuf), channel->writebuf, channel->writebuf ? 0 : cbuf_getused(channel->extrabuf))) diff --git a/svr-auth.c b/svr-auth.c index f0fca38..d0eba9b 100644 --- a/svr-auth.c +++ b/svr-auth.c @@ -315,14 +315,15 @@ void send_msg_userauth_failure(int partial, int incrfail) { buf_setpos(typebuf, 0); buf_putstring(ses.writepayload, buf_getptr(typebuf, typebuf->len), typebuf->len); + + TRACE(("auth fail: methods %d, '%s'", ses.authstate.authtypes, + buf_getptr(typebuf, typebuf->len))); + buf_free(typebuf); buf_putbyte(ses.writepayload, partial ? 1 : 0); encrypt_packet(); - TRACE(("auth fail: methods %d, '%s'", ses.authstate.authtypes, - buf_getptr(typebuf, typebuf->len))); - if (incrfail) { usleep(300000); /* XXX improve this */ ses.authstate.failcount++; -- cgit v1.2.3 From d0537c7506af0f7193fd11a63ccbac04a464485a Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Mon, 12 Jun 2006 14:41:32 +0000 Subject: Make the dbclient password prompt more useful --HG-- extra : convert_revision : 3bcfb35f7a6065dafbd695d943b95d64efff1c99 --- auth.h | 2 +- cli-auth.c | 4 ++-- cli-authpasswd.c | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'cli-auth.c') diff --git a/auth.h b/auth.h index c407ad5..661265a 100644 --- a/auth.h +++ b/auth.h @@ -52,7 +52,7 @@ void cli_pubkeyfail(); void cli_auth_password(); int cli_auth_pubkey(); void cli_auth_interactive(); -char* getpass_or_cancel(); +char* getpass_or_cancel(char* prompt); #define MAX_USERNAME_LEN 25 /* arbitrary for the moment */ diff --git a/cli-auth.c b/cli-auth.c index ba4cf6c..4c17a21 100644 --- a/cli-auth.c +++ b/cli-auth.c @@ -281,11 +281,11 @@ void cli_auth_try() { /* A helper for getpass() that exits if the user cancels. The returned * password is statically allocated by getpass() */ -char* getpass_or_cancel() +char* getpass_or_cancel(char* prompt) { char* password = NULL; - password = getpass("Password: "); + password = getpass(prompt); /* 0x03 is a ctrl-c character in the buffer. */ if (password == NULL || strchr(password, '\3') != NULL) { diff --git a/cli-authpasswd.c b/cli-authpasswd.c index 5dffac4..2500a25 100644 --- a/cli-authpasswd.c +++ b/cli-authpasswd.c @@ -116,16 +116,19 @@ static char *gui_getpass(const char *prompt) { void cli_auth_password() { char* password = NULL; + char prompt[80]; TRACE(("enter cli_auth_password")) CHECKCLEARTOWRITE(); + snprintf(prompt, sizeof(prompt), "%s@%s's password: ", + cli_opts.username, cli_opts.remotehost); #ifdef ENABLE_CLI_ASKPASS_HELPER if (want_askpass()) - password = gui_getpass("Password: "); + password = gui_getpass(prompt); else #endif - password = getpass_or_cancel("Password: "); + password = getpass_or_cancel(prompt); buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST); -- cgit v1.2.3