diff svr-session.c @ 478:d4f32c3443ac dbclient-netcat-alike

propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2) to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 14 Sep 2008 06:47:51 +0000
parents 4317be8b7cf9
children 52a644e7b8e1 e3db1f7a2e43
line wrap: on
line diff
--- a/svr-session.c	Tue Mar 21 16:16:41 2006 +0000
+++ b/svr-session.c	Sun Sep 14 06:47:51 2008 +0000
@@ -77,8 +77,6 @@
 void svr_session(int sock, int childpipe, 
 		char* remotehost, char *addrstring) {
 
-	struct timeval timeout;
-
     reseedrandom();
 
 	crypto_init();
@@ -91,11 +89,7 @@
 	chaninitialise(svr_chantypes);
 	svr_chansessinitialise();
 
-	if (gettimeofday(&timeout, 0) < 0) {
-		dropbear_exit("Error getting time");
-	}
-
-	ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT;
+	ses.connect_time = time(NULL);
 
 	/* set up messages etc */
 	ses.remoteclosed = svr_remoteclosed;
@@ -136,12 +130,12 @@
 		/* user has authenticated */
 		snprintf(fmtbuf, sizeof(fmtbuf),
 				"exit after auth (%s): %s", 
-				ses.authstate.printableuser, format);
-	} else if (ses.authstate.printableuser) {
+				ses.authstate.pw_name, format);
+	} else if (ses.authstate.pw_name) {
 		/* we have a potential user */
 		snprintf(fmtbuf, sizeof(fmtbuf), 
 				"exit before auth (user '%s', %d fails): %s",
-				ses.authstate.printableuser, ses.authstate.failcount, format);
+				ses.authstate.pw_name, ses.authstate.failcount, format);
 	} else {
 		/* before userauth */
 		snprintf(fmtbuf, sizeof(fmtbuf), 
@@ -181,10 +175,15 @@
 
 	if (!svr_opts.usingsyslog || havetrace)
 	{
+		struct tm * local_tm = NULL;
 		timesec = time(NULL);
-		if (strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", 
-					localtime(&timesec)) == 0) {
-			datestr[0] = '?'; datestr[1] = '\0';
+		local_tm = localtime(&timesec);
+		if (local_tm == NULL
+			|| strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", 
+						localtime(&timesec)) == 0)
+		{
+			/* upon failure, just print the epoch-seconds time. */
+			snprintf(datestr, sizeof(datestr), "%d", timesec);
 		}
 		fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf);
 	}