changeset 1800:c584b5602bd8

Return errstring on connect failure
author Matt Johnston <matt@ucc.asn.au>
date Fri, 05 Mar 2021 21:13:20 +0800
parents 8df3d6aa5f23
children 4983a6bc1f51
files channel.h common-channel.c
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/channel.h	Thu Mar 04 23:57:12 2021 +0800
+++ b/channel.h	Fri Mar 05 21:13:20 2021 +0800
@@ -104,7 +104,7 @@
 	void (*cleanup)(const struct Channel*);
 };
 
-/* Callback for connect_remote */
+/* Callback for connect_remote. errstring may be NULL if result == DROPBEAR_SUCCESS */
 void channel_connect_done(int result, int sock, void* user_data, const char* errstring);
 
 void chaninitialise(const struct ChanType *chantypes[]);
--- a/common-channel.c	Thu Mar 04 23:57:12 2021 +0800
+++ b/common-channel.c	Fri Mar 05 21:13:20 2021 +0800
@@ -356,8 +356,7 @@
  * if so, set up the channel properly. Otherwise, the channel is cleaned up, so
  * it is important that the channel reference isn't used after a call to this
  * function */
-void channel_connect_done(int result, int sock, void* user_data, const char* UNUSED(errstring)) {
-
+void channel_connect_done(int result, int sock, void* user_data, const char* errstring) {
 	struct Channel *channel = user_data;
 
 	TRACE(("enter channel_connect_done"))
@@ -373,9 +372,9 @@
 	else
 	{
 		send_msg_channel_open_failure(channel->remotechan,
-				SSH_OPEN_CONNECT_FAILED, "", "");
+				SSH_OPEN_CONNECT_FAILED, errstring, "");
 		remove_channel(channel);
-		TRACE(("leave check_in_progress: fail"))
+		TRACE(("leave check_in_progress: fail. internal errstring: %s", errstring))
 	}
 }