From 484516da516037d37747319e9b7cff91bffb6a4a Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Sun, 31 Mar 2013 23:48:25 +0800
Subject: [PATCH] Send an auth packet straight away, save another roundtrip

This needs a bit of testing to make sure it doesn't have side-effects.
---
 cli-auth.c   | 9 +++++----
 sysoptions.h | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/cli-auth.c b/cli-auth.c
index 321cbf30..7dc101fb 100644
--- a/cli-auth.c
+++ b/cli-auth.c
@@ -40,11 +40,12 @@ void cli_authinitialise() {
 
 /* Send a "none" auth request to get available methods */
 void cli_auth_getmethods() {
-
 	TRACE(("enter cli_auth_getmethods"))
-
+#ifdef CLI_IMMEDIATE_AUTH
+	ses.authstate.authtypes = AUTH_TYPE_PUBKEY | AUTH_TYPE_PASSWORD | AUTH_TYPE_INTERACT;
+	cli_auth_try();
+#else
 	CHECKCLEARTOWRITE();
-
 	buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST);
 	buf_putstring(ses.writepayload, cli_opts.username, 
 			strlen(cli_opts.username));
@@ -53,8 +54,8 @@ void cli_auth_getmethods() {
 	buf_putstring(ses.writepayload, "none", 4); /* 'none' method */
 
 	encrypt_packet();
+#endif
 	TRACE(("leave cli_auth_getmethods"))
-
 }
 
 void recv_msg_userauth_banner() {
diff --git a/sysoptions.h b/sysoptions.h
index 8c591ea5..6e602947 100644
--- a/sysoptions.h
+++ b/sysoptions.h
@@ -188,6 +188,9 @@
 #define DROPBEAR_KEY_LINES /* ie we're using authorized_keys or known_hosts */
 #endif
 
+/* Send an auth request straight away rather than trying "none" type to get a list */
+#define CLI_IMMEDIATE_AUTH
+
 /* Changing this is inadvisable, it appears to have problems
  * with flushing compressed data */
 #define DROPBEAR_ZLIB_MEM_LEVEL 8
-- 
GitLab