/* 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); }
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); }
/* this is what can be called to write arbitrary log messages */ void dropbear_log(int priority, const char* format, ...) { va_list param; va_start(param, format); _dropbear_log(priority, format, param); va_end(param); }
static void generic_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s", format); _dropbear_log(LOG_INFO, fmtbuf, param); exit(exitcode); }
static void fwd_failed(const char* format, ...) { va_list param; va_start(param, format); if (cli_opts.exit_on_fwd_failure) { _dropbear_exit(EXIT_FAILURE, format, param); } else { _dropbear_log(LOG_WARNING, format, param); } va_end(param); }
/* failure exit - format must be <= 100 chars */ void svr_dropbear_exit(int exitcode, const char* format, va_list param) { char fmtbuf[300]; int i; if (!sessinitdone) { /* before session init */ snprintf(fmtbuf, sizeof(fmtbuf), "Early exit: %s", format); } else if (ses.authstate.authdone) { /* user has authenticated */ snprintf(fmtbuf, sizeof(fmtbuf), "Exit (%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 USE_VFORK /* For uclinux only the main server process should cleanup - we don't want * forked children doing that */ if (svr_ses.server_pid == getpid()) #endif { /* must be after we've done with username etc */ session_cleanup(); } if (svr_opts.hostkey) { sign_key_free(svr_opts.hostkey); svr_opts.hostkey = NULL; } for (i = 0; i < DROPBEAR_MAX_PORTS; i++) { m_free(svr_opts.addresses[i]); m_free(svr_opts.ports[i]); } 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); }
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:%s exited: %s", cli_opts.username, cli_opts.remotehost, cli_opts.remoteport, format); } /* Do the cleanup first, since then the terminal will be reset */ session_cleanup(); /* Avoid printing onwards from terminal cruft */ fprintf(stderr, "\n"); _dropbear_log(LOG_INFO, fmtbuf, param); exit(exitcode); }