# HG changeset patch
# User Matt Johnston <matt@ucc.asn.au>
# Date 1189729184 0
# Node ID bde853a9e6805d2a249c26ea9f23bdc261bf52b2
# Parent  f4addc06745b02a2cb35b607f15cbfcbc20cdb32
Add support for SSH_ASKPASS_ALWAYS env variable for dbclient. If it
(and also SSH_ASKPASS) is set then dbclient will use an external askpass
program regardless of whether DISPLAY is set or stdin is a TTY. Suggested
by Davyd Madeley for handheld devices.

diff -r f4addc06745b -r bde853a9e680 cli-authpasswd.c
--- a/cli-authpasswd.c	Tue Sep 11 12:00:18 2007 +0000
+++ b/cli-authpasswd.c	Fri Sep 14 00:19:44 2007 +0000
@@ -38,7 +38,9 @@
 	char* askpass_prog = NULL;
 
 	askpass_prog = getenv("SSH_ASKPASS");
-	return askpass_prog && !isatty(STDIN_FILENO) && getenv("DISPLAY");
+	return askpass_prog && 
+		((!isatty(STDIN_FILENO) && getenv("DISPLAY") )
+		 	|| getenv("SSH_ASKPASS_ALWAYS"));
 }
 
 /* returns a statically allocated password from a helper app, or NULL
@@ -125,10 +127,16 @@
 				cli_opts.username, cli_opts.remotehost);
 #ifdef ENABLE_CLI_ASKPASS_HELPER
 	if (want_askpass())
+	{
 		password = gui_getpass(prompt);
-	else
+		if (!password) {
+			dropbear_exit("No password");
+		}
+	} else
 #endif
+	{
 		password = getpass_or_cancel(prompt);
+	}
 
 	buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST);