aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cerberus.c17
-rw-r--r--src/cerberus.h4
2 files changed, 17 insertions, 4 deletions
diff --git a/src/cerberus.c b/src/cerberus.c
index adf5b6b..d80e548 100644
--- a/src/cerberus.c
+++ b/src/cerberus.c
@@ -324,20 +324,20 @@ void do_login(int argc, char** argv)
initialise_login(hostname, username, read_passphrase);
if (skip_auth == 0)
ret = authenticate_login();
+ /* Passphrase entered, turn off timeout */
+ alarm(0);
#endif
if (ret == 2)
printf("(auto-authenticated)\n");
if (ret == 0)
{
+ preexit();
fork_exec_wait_hook(HOOK_DENIED, argc, argv);
sleep(FAILURE_SLEEP);
_exit(1);
}
#if AUTH > 0
- /* Passphrase entered, turn off timeout */
- alarm(0);
-
/* Wipe and free the passphrase from the memory */
destroy_passphrase();
@@ -405,7 +405,18 @@ void do_login(int argc, char** argv)
}
+
#if AUTH > 0
+void preexit(void)
+{
+ /* Wipe and free the passphrase from the memory */
+ destroy_passphrase();
+
+ /* Reset terminal settings */
+ passphrase_reenable_echo();
+}
+
+
/**
* Read passphrase from the terminal
*
diff --git a/src/cerberus.h b/src/cerberus.h
index 9960fa7..0488174 100644
--- a/src/cerberus.h
+++ b/src/cerberus.h
@@ -56,9 +56,11 @@ void exec_hook(int hook, int argc, char** argv);
void do_login(int argc, char** argv);
#if AUTH > 0
+void preexit(void);
char* read_passphrase(void);
#else
-#define read_passphrase NULL
+#define preexit() /* do nothing */
+#define read_passphrase() NULL
#endif
void destroy_passphrase(void) __attribute__((optimize("-O0")));