Blame SOURCES/openssh-6.6p1-set_remote_ipaddr.patch

017ff1
diff --git a/canohost.c b/canohost.c
017ff1
index 97ce58c..1f9320a 100644
017ff1
--- a/canohost.c
017ff1
+++ b/canohost.c
017ff1
@@ -338,6 +338,21 @@ clear_cached_addr(void)
017ff1
 	cached_port = -1;
017ff1
 }
017ff1
 
017ff1
+void set_remote_ipaddr(void) {
017ff1
+	if (canonical_host_ip != NULL)
017ff1
+		free(canonical_host_ip);
017ff1
+
017ff1
+	if (packet_connection_is_on_socket()) {
017ff1
+		canonical_host_ip =
017ff1
+		    get_peer_ipaddr(packet_get_connection_in());
017ff1
+		if (canonical_host_ip == NULL)
017ff1
+			cleanup_exit(255);
017ff1
+	} else {
017ff1
+		/* If not on socket, return UNKNOWN. */
017ff1
+		canonical_host_ip = xstrdup("UNKNOWN");
017ff1
+	}
017ff1
+}
017ff1
+
017ff1
 /*
017ff1
  * Returns the IP-address of the remote host as a string.  The returned
017ff1
  * string must not be freed.
017ff1
@@ -347,17 +362,9 @@ const char *
017ff1
 get_remote_ipaddr(void)
017ff1
 {
017ff1
 	/* Check whether we have cached the ipaddr. */
017ff1
-	if (canonical_host_ip == NULL) {
017ff1
-		if (packet_connection_is_on_socket()) {
017ff1
-			canonical_host_ip =
017ff1
-			    get_peer_ipaddr(packet_get_connection_in());
017ff1
-			if (canonical_host_ip == NULL)
017ff1
-				cleanup_exit(255);
017ff1
-		} else {
017ff1
-			/* If not on socket, return UNKNOWN. */
017ff1
-			canonical_host_ip = xstrdup("UNKNOWN");
017ff1
-		}
017ff1
-	}
017ff1
+	if (canonical_host_ip == NULL)
017ff1
+		set_remote_ipaddr();
017ff1
+
017ff1
 	return canonical_host_ip;
017ff1
 }
017ff1
 
017ff1
diff --git a/canohost.h b/canohost.h
017ff1
index 4c8636f..4079953 100644
017ff1
--- a/canohost.h
017ff1
+++ b/canohost.h
017ff1
@@ -13,6 +13,7 @@
017ff1
  */
017ff1
 
017ff1
 const char	*get_canonical_hostname(int);
017ff1
+void		 set_remote_ipaddr(void);
017ff1
 const char	*get_remote_ipaddr(void);
017ff1
 const char	*get_remote_name_or_ip(u_int, int);
017ff1
 
017ff1
diff --git a/sshconnect.c b/sshconnect.c
017ff1
index e636f33..451a58b 100644
017ff1
--- a/sshconnect.c
017ff1
+++ b/sshconnect.c
017ff1
@@ -62,6 +62,7 @@
017ff1
 #include "monitor_fdpass.h"
017ff1
 #include "ssh2.h"
017ff1
 #include "version.h"
017ff1
+#include "canohost.h"
017ff1
 
017ff1
 char *client_version_string = NULL;
017ff1
 char *server_version_string = NULL;
017ff1
@@ -170,6 +171,7 @@ ssh_proxy_fdpass_connect(const char *host, u_short port,
017ff1
 
017ff1
 	/* Set the connection file descriptors. */
017ff1
 	packet_set_connection(sock, sock);
017ff1
+	set_remote_ipaddr();
017ff1
 
017ff1
 	return 0;
017ff1
 }
017ff1
@@ -492,6 +494,7 @@ ssh_connect_direct(const char *host, struct addrinfo *aitop,
017ff1
 
017ff1
 	/* Set the connection. */
017ff1
 	packet_set_connection(sock, sock);
017ff1
+	set_remote_ipaddr();
017ff1
 
017ff1
 	return 0;
017ff1
 }