summaryrefslogtreecommitdiffhomepage
path: root/cli-session.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2020-10-18 12:17:39 +0800
committerMatt Johnston <matt@ucc.asn.au>2020-10-18 12:17:39 +0800
commit282fc81981c57e53b6aaa6d3189b66b4a229f0a8 (patch)
treeb11528bbd54f18273297e00487e43ec5e7f32f9a /cli-session.c
parentcc1b07dcf170890c34c43f247334dbc78d6f8647 (diff)
Get client fuzzer building and starting (fails straight away)
--HG-- branch : fuzz
Diffstat (limited to 'cli-session.c')
-rw-r--r--cli-session.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/cli-session.c b/cli-session.c
index f42ea90..bc83564 100644
--- a/cli-session.c
+++ b/cli-session.c
@@ -407,3 +407,62 @@ static void recv_msg_global_request_cli(void) {
/* Send a proper rejection */
send_msg_request_failure();
}
+
+void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
+ char exitmsg[150];
+ char fullmsg[300];
+
+ /* Note that exit message must be rendered before session cleanup */
+
+ /* Render the formatted exit message */
+ vsnprintf(exitmsg, sizeof(exitmsg), format, param);
+ TRACE(("Exited, cleaning up: %s", exitmsg))
+
+ /* Add the prefix depending on session/auth state */
+ if (!ses.init_done) {
+ snprintf(fullmsg, sizeof(fullmsg), "Exited: %s", exitmsg);
+ } else {
+ snprintf(fullmsg, sizeof(fullmsg),
+ "Connection to %s@%s:%s exited: %s",
+ cli_opts.username, cli_opts.remotehost,
+ cli_opts.remoteport, exitmsg);
+ }
+
+ /* 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, "%s", fullmsg);
+
+#if DROPBEAR_FUZZ
+ if (fuzz.do_jmp) {
+ longjmp(fuzz.jmp, 1);
+ }
+#endif
+
+ exit(exitcode);
+}
+
+void cli_dropbear_log(int priority, const char* format, va_list param) {
+
+ char printbuf[1024];
+ const char *name;
+
+ name = cli_opts.progname;
+ if (!name) {
+ name = "dbclient";
+ }
+
+ vsnprintf(printbuf, sizeof(printbuf), format, param);
+
+#ifndef DISABLE_SYSLOG
+ if (opts.usingsyslog) {
+ syslog(priority, "%s", printbuf);
+ }
+#endif
+
+ fprintf(stderr, "%s: %s\n", name, printbuf);
+ fflush(stderr);
+}
+