aboutsummaryrefslogtreecommitdiffstats
path: root/src/cerberus.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-11-19 02:19:08 +0100
committerMattias Andrée <maandree@operamail.com>2013-11-19 02:19:08 +0100
commitc3a88777291223b4ed750a3450abc373ecab8ecb (patch)
tree44065ac3ac76791d6f77452abd2d8e94cbc911f6 /src/cerberus.c
parentm (diff)
downloadlibpassphrase-c3a88777291223b4ed750a3450abc373ecab8ecb.tar.gz
libpassphrase-c3a88777291223b4ed750a3450abc373ecab8ecb.tar.bz2
libpassphrase-c3a88777291223b4ed750a3450abc373ecab8ecb.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/cerberus.c')
-rw-r--r--src/cerberus.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cerberus.c b/src/cerberus.c
index 6f0ce91..01cbe08 100644
--- a/src/cerberus.c
+++ b/src/cerberus.c
@@ -44,6 +44,10 @@ int main(int argc, char** argv)
do_login(argc, argv);
+ /* Ignore signals */
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+
/* Wait for the login shell to exit */
waitpid(child_pid, &_status, 0);
@@ -220,6 +224,12 @@ void do_login(int argc, char** argv)
set_environ(entry, preserve_env);
+ /* Stop signal handling */
+ signal(SIGALRM, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ signal(SIGTSTP, SIG_IGN);
+
+
child_pid = fork();
/* vfork cannot be used as the child changes the user,
the parent would not be able to chown the TTY */
@@ -227,10 +237,19 @@ void do_login(int argc, char** argv)
if (child_pid == -1)
{
perror("fork");
+ sleep(ERROR_SLEEP);
_exit(1);
}
else if (child_pid == 0)
{
+ /* In case the shell does not do this */
+ setsid();
+
+ /* Set controlling terminal */
+ if (ioctl(STDIN_FILENO, TIOCSCTTY, 1))
+ perror("TIOCSCTTY");
+ signal(SIGINT, SIG_DFL);
+
/* Partial login */
/* TODO set supplemental groups */
set_user(entry);