Mercurial > dropbear
comparison 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 |
comparison
equal
deleted
inserted
replaced
296:6b41e2cbf071 | 478:d4f32c3443ac |
---|---|
75 }; | 75 }; |
76 | 76 |
77 void svr_session(int sock, int childpipe, | 77 void svr_session(int sock, int childpipe, |
78 char* remotehost, char *addrstring) { | 78 char* remotehost, char *addrstring) { |
79 | 79 |
80 struct timeval timeout; | |
81 | |
82 reseedrandom(); | 80 reseedrandom(); |
83 | 81 |
84 crypto_init(); | 82 crypto_init(); |
85 common_session_init(sock, remotehost); | 83 common_session_init(sock, remotehost); |
86 | 84 |
89 svr_ses.addrstring = addrstring; | 87 svr_ses.addrstring = addrstring; |
90 svr_authinitialise(); | 88 svr_authinitialise(); |
91 chaninitialise(svr_chantypes); | 89 chaninitialise(svr_chantypes); |
92 svr_chansessinitialise(); | 90 svr_chansessinitialise(); |
93 | 91 |
94 if (gettimeofday(&timeout, 0) < 0) { | 92 ses.connect_time = time(NULL); |
95 dropbear_exit("Error getting time"); | |
96 } | |
97 | |
98 ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT; | |
99 | 93 |
100 /* set up messages etc */ | 94 /* set up messages etc */ |
101 ses.remoteclosed = svr_remoteclosed; | 95 ses.remoteclosed = svr_remoteclosed; |
102 | 96 |
103 /* packet handlers */ | 97 /* packet handlers */ |
134 "premature exit: %s", format); | 128 "premature exit: %s", format); |
135 } else if (ses.authstate.authdone) { | 129 } else if (ses.authstate.authdone) { |
136 /* user has authenticated */ | 130 /* user has authenticated */ |
137 snprintf(fmtbuf, sizeof(fmtbuf), | 131 snprintf(fmtbuf, sizeof(fmtbuf), |
138 "exit after auth (%s): %s", | 132 "exit after auth (%s): %s", |
139 ses.authstate.printableuser, format); | 133 ses.authstate.pw_name, format); |
140 } else if (ses.authstate.printableuser) { | 134 } else if (ses.authstate.pw_name) { |
141 /* we have a potential user */ | 135 /* we have a potential user */ |
142 snprintf(fmtbuf, sizeof(fmtbuf), | 136 snprintf(fmtbuf, sizeof(fmtbuf), |
143 "exit before auth (user '%s', %d fails): %s", | 137 "exit before auth (user '%s', %d fails): %s", |
144 ses.authstate.printableuser, ses.authstate.failcount, format); | 138 ses.authstate.pw_name, ses.authstate.failcount, format); |
145 } else { | 139 } else { |
146 /* before userauth */ | 140 /* before userauth */ |
147 snprintf(fmtbuf, sizeof(fmtbuf), | 141 snprintf(fmtbuf, sizeof(fmtbuf), |
148 "exit before auth: %s", format); | 142 "exit before auth: %s", format); |
149 } | 143 } |
179 havetrace = debug_trace; | 173 havetrace = debug_trace; |
180 #endif | 174 #endif |
181 | 175 |
182 if (!svr_opts.usingsyslog || havetrace) | 176 if (!svr_opts.usingsyslog || havetrace) |
183 { | 177 { |
178 struct tm * local_tm = NULL; | |
184 timesec = time(NULL); | 179 timesec = time(NULL); |
185 if (strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", | 180 local_tm = localtime(×ec); |
186 localtime(×ec)) == 0) { | 181 if (local_tm == NULL |
187 datestr[0] = '?'; datestr[1] = '\0'; | 182 || strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", |
183 localtime(×ec)) == 0) | |
184 { | |
185 /* upon failure, just print the epoch-seconds time. */ | |
186 snprintf(datestr, sizeof(datestr), "%d", timesec); | |
188 } | 187 } |
189 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); | 188 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); |
190 } | 189 } |
191 } | 190 } |
192 | 191 |