static void cli_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; if (!sessinitdone) { snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s", format); } else { snprintf(fmtbuf, sizeof(fmtbuf), "Connection to %s@%s exited: %s", cli_opts.username, cli_opts.remote_name_str, format); #if 0 "Connection to %s@%s:%s exited: %s", cli_opts.username, cli_opts.remotehost, cli_opts.remoteport, format); #endif } /* Do the cleanup first, since then the terminal will be reset */ cli_session_cleanup(); common_session_cleanup(); _dropbear_log(LOG_INFO, fmtbuf, param); exit(exitcode); }
/* failure exit - format must be <= 100 chars */ void svr_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; if (!sessinitdone) { /* before session init */ snprintf(fmtbuf, sizeof(fmtbuf), "premature exit: %s", format); } else if (ses.authstate.authdone) { /* user has authenticated */ snprintf(fmtbuf, sizeof(fmtbuf), "exit after auth (%s): %s", ses.authstate.printableuser, format); } else if (ses.authstate.printableuser) { /* we have a potential user */ snprintf(fmtbuf, sizeof(fmtbuf), "exit before auth (user '%s', %d fails): %s", ses.authstate.printableuser, ses.authstate.failcount, format); } else { /* before userauth */ snprintf(fmtbuf, sizeof(fmtbuf), "exit before auth: %s", format); } _dropbear_log(LOG_INFO, fmtbuf, param); /* must be after we've done with username etc */ common_session_cleanup(); exit(exitcode); }
/* failure exit - format must be <= 100 chars */ void svr_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; if (!sessinitdone) { /* before session init */ snprintf(fmtbuf, sizeof(fmtbuf), "premature exit: %s", format); } else if (ses.authstate.authdone) { /* user has authenticated */ snprintf(fmtbuf, sizeof(fmtbuf), "exit after auth (%s): %s", 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.pw_name, ses.authstate.failcount, format); } else { /* before userauth */ snprintf(fmtbuf, sizeof(fmtbuf), "exit before auth: %s", format); } _dropbear_log(LOG_INFO, fmtbuf, param); #ifdef __uClinux__ /* only the main server process should cleanup - we don't want * forked children doing that */ if (svr_ses.server_pid == getpid()) #else if (1) #endif { /* free potential public key options */ svr_pubkey_options_cleanup(); /* must be after we've done with username etc */ common_session_cleanup(); } exit(exitcode); }