aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJulien Dessaux2018-08-26 15:55:38 +0200
committerJulien Dessaux2018-08-26 16:04:11 +0200
commitbeff818f25ae69cfe8501e18271b2509320de8df (patch)
treed132e9d366aaebac9f7b91b8a63fcafbbe550af8 /src/main.c
parentAdded address sanitization and fixed found bugs (diff)
downloadbastion-beff818f25ae69cfe8501e18271b2509320de8df.tar.gz
bastion-beff818f25ae69cfe8501e18271b2509320de8df.tar.bz2
bastion-beff818f25ae69cfe8501e18271b2509320de8df.zip
Added session recording with https://github.com/kilobyte/termrec
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index c3d7108..4f475ee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,12 +14,13 @@ static void sigchld_handler(int signo) {
}
/* SIGINT handler for cleaning up on forced exit. */
-static ssh_bind sshbind;
-static ssh_session session;
+static ssh_bind sshbind = NULL;
+static ssh_session session = NULL;
__attribute__((noreturn)) static void sigint_handler(int signo)
{
(void) signo;
+ ssh_disconnect(session);
ssh_free(session);
ssh_bind_free(sshbind);
ssh_finalize();
@@ -75,8 +76,10 @@ int main()
fprintf(stderr, "Error initializing ssh_session\n");
break;
}
+#ifdef LIBSSH_VERBOSE_OUTPOUT
int verbosity = SSH_LOG_PROTOCOL;
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
+#endif
// Blocks until there is a new incoming connection
if (ssh_bind_accept(sshbind,session) == SSH_OK){
@@ -87,6 +90,7 @@ int main()
sigaction(SIGCHLD, &sa, NULL);
/* Remove socket binding, which allows us to restart the parent process, without terminating existing sessions. */
ssh_bind_free(sshbind);
+ sshbind = NULL;
ssh_event event = ssh_event_new();
if (event != NULL) {