diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-11-19 02:19:08 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-11-19 02:19:08 +0100 | 
| commit | c3a88777291223b4ed750a3450abc373ecab8ecb (patch) | |
| tree | 44065ac3ac76791d6f77452abd2d8e94cbc911f6 /src | |
| parent | m (diff) | |
| download | libpassphrase-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')
| -rw-r--r-- | src/cerberus.c | 19 | ||||
| -rw-r--r-- | src/cerberus.h | 3 | ||||
| -rw-r--r-- | src/login.c | 3 | 
3 files changed, 25 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); diff --git a/src/cerberus.h b/src/cerberus.h index e195245..706925a 100644 --- a/src/cerberus.h +++ b/src/cerberus.h @@ -26,7 +26,10 @@  #include <signal.h>  #include <pwd.h>  #include <errno.h> +#include <stropts.h> +#include <termios.h>  #include <sys/wait.h> +#include <sys/ioctl.h>  #ifdef USE_TTY_GROUP  #include <grp.h>  #endif diff --git a/src/login.c b/src/login.c index 3ad1204..32f118f 100644 --- a/src/login.c +++ b/src/login.c @@ -193,5 +193,8 @@ void exec_shell(struct passwd* entry)    *(child_argv + child_argc) = NULL;    execvp(*child_argv, child_argv + 1); +  perror("execvp"); +  sleep(ERROR_SLEEP); +  _exit(1);  } | 
