comparison svr-session.c @ 1316:2c9dac2d6707

merge 2016.74
author Matt Johnston <matt@ucc.asn.au>
date Thu, 21 Jul 2016 23:38:42 +0800
parents 750ec4ec4cbe b66a483f3dcb
children 3fdd8c5a0195 e8f67918fdc9
comparison
equal deleted inserted replaced
1298:251c5f7a6e96 1316:2c9dac2d6707
142 142
143 } 143 }
144 144
145 /* failure exit - format must be <= 100 chars */ 145 /* failure exit - format must be <= 100 chars */
146 void svr_dropbear_exit(int exitcode, const char* format, va_list param) { 146 void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
147 147 char exitmsg[150];
148 char fmtbuf[300]; 148 char fullmsg[300];
149 int i; 149 int i;
150 150
151 /* Render the formatted exit message */
152 vsnprintf(exitmsg, sizeof(exitmsg), format, param);
153
154 /* Add the prefix depending on session/auth state */
151 if (!sessinitdone) { 155 if (!sessinitdone) {
152 /* before session init */ 156 /* before session init */
153 snprintf(fmtbuf, sizeof(fmtbuf), 157 snprintf(fullmsg, sizeof(fullmsg), "Early exit: %s", exitmsg);
154 "Early exit: %s", format);
155 } else if (ses.authstate.authdone) { 158 } else if (ses.authstate.authdone) {
156 /* user has authenticated */ 159 /* user has authenticated */
157 snprintf(fmtbuf, sizeof(fmtbuf), 160 snprintf(fullmsg, sizeof(fullmsg),
158 "Exit (%s): %s", 161 "Exit (%s): %s",
159 ses.authstate.pw_name, format); 162 ses.authstate.pw_name, exitmsg);
160 } else if (ses.authstate.pw_name) { 163 } else if (ses.authstate.pw_name) {
161 /* we have a potential user */ 164 /* we have a potential user */
162 snprintf(fmtbuf, sizeof(fmtbuf), 165 snprintf(fullmsg, sizeof(fullmsg),
163 "Exit before auth (user '%s', %u fails): %s", 166 "Exit before auth (user '%s', %u fails): %s",
164 ses.authstate.pw_name, ses.authstate.failcount, format); 167 ses.authstate.pw_name, ses.authstate.failcount, exitmsg);
165 } else { 168 } else {
166 /* before userauth */ 169 /* before userauth */
167 snprintf(fmtbuf, sizeof(fmtbuf), 170 snprintf(fullmsg, sizeof(fullmsg), "Exit before auth: %s", exitmsg);
168 "Exit before auth: %s", format); 171 }
169 } 172
170 173 dropbear_log(LOG_INFO, "%s", fullmsg);
171 _dropbear_log(LOG_INFO, fmtbuf, param);
172 174
173 #if DROPBEAR_VFORK 175 #if DROPBEAR_VFORK
174 /* For uclinux only the main server process should cleanup - we don't want 176 /* For uclinux only the main server process should cleanup - we don't want
175 * forked children doing that */ 177 * forked children doing that */
176 if (svr_ses.server_pid == getpid()) 178 if (svr_ses.server_pid == getpid())