summaryrefslogtreecommitdiffhomepage
path: root/svr-session.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2008-09-14 06:47:51 +0000
committerMatt Johnston <matt@ucc.asn.au>2008-09-14 06:47:51 +0000
commit1c72a35ddb79eede31657a450b8ba35aed24c79e (patch)
treee6f6ae8bac919e2696678d7a680dce410a1ea91a /svr-session.c
parentcdbe853595d1ba06be4127d86c60a9bc2e9e3545 (diff)
parent460bf4382257a262fda862f66d6fe97c749f5bb7 (diff)
propagate from branch 'au.asn.ucc.matt.dropbear' (head f21045c791002d81fc6b8dde6537ea481e513eb2)
to branch 'au.asn.ucc.matt.dropbear.dbclient-netcat-alike' (head d1f69334581dc4c35f9ca16aa5355074c9dd315d) --HG-- branch : dbclient-netcat-alike extra : convert_revision : 22bbe895accc3995b48f07b556e45d546ff1ce5d
Diffstat (limited to 'svr-session.c')
-rw-r--r--svr-session.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/svr-session.c b/svr-session.c
index 70029f8..5a8364a 100644
--- a/svr-session.c
+++ b/svr-session.c
@@ -77,8 +77,6 @@ static const struct ChanType *svr_chantypes[] = {
void svr_session(int sock, int childpipe,
char* remotehost, char *addrstring) {
- struct timeval timeout;
-
reseedrandom();
crypto_init();
@@ -91,11 +89,7 @@ void svr_session(int sock, int childpipe,
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 @@ void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
/* 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 @@ void svr_dropbear_log(int priority, const char* format, va_list param) {
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);
}