changeset 572:8fd0ac8c8cab

Move remotehost into svr_ses structure since we can't look it up once we've forked (the connection socket has been closed). Fixes inetd mode.
author Matt Johnston <matt@ucc.asn.au>
date Sat, 05 Sep 2009 11:40:00 +0000
parents 281ed8384eb4
children d3ea8b9672f0
files session.h svr-chansession.c svr-session.c
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/session.h	Wed Sep 02 15:17:14 2009 +0000
+++ b/session.h	Sat Sep 05 11:40:00 2009 +0000
@@ -211,6 +211,9 @@
 	/* The numeric address they connected from, used for logging */
 	char * addrstring;
 
+	/* The resolved remote address, used for lastlog etc */
+	char *remotehost;
+
 #ifdef __uClinux__
 	pid_t server_pid;
 #endif
--- a/svr-chansession.c	Wed Sep 02 15:17:14 2009 +0000
+++ b/svr-chansession.c	Sat Sep 05 11:40:00 2009 +0000
@@ -253,12 +253,9 @@
 
 static struct logininfo* 
 chansess_login_alloc(struct ChanSess *chansess) {
-	char *remotehost;
 	struct logininfo * li;
-	get_socket_address(ses.sock_in, NULL, NULL, &remotehost, NULL, 1);
 	li = login_alloc_entry(chansess->pid, ses.authstate.username,
-			remotehost, chansess->tty);
-	m_free(remotehost);	
+			svr_ses.remotehost, chansess->tty);
 	return li;
 }
 
--- a/svr-session.c	Wed Sep 02 15:17:14 2009 +0000
+++ b/svr-session.c	Sat Sep 05 11:40:00 2009 +0000
@@ -101,6 +101,9 @@
 	m_free(host);
 	m_free(port);
 
+	get_socket_address(ses.sock_in, NULL, NULL, 
+			&svr_ses.remotehost, NULL, 1);
+
 	/* set up messages etc */
 	ses.remoteclosed = svr_remoteclosed;