opendoas

my fork of doas with custom prompt
git clone git://git.kocotian.pl/opendoas.git
Log | Files | Refs | README | LICENSE

commit 4b1b24b7efeda7ca04db707a0a1e89a8868ca7d8
parent 3018a665160b917f70176e0d623fdd0afb10cb3d
Author: Duncaen <mail@duncano.de>
Date:   Fri,  6 Apr 2018 18:16:30 +0200

pam: check watch child pid

Diffstat:
Mpam.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/pam.c b/pam.c @@ -191,7 +191,7 @@ watchsession(pid_t child) status = 1; close: - if (caught_signal) { + if (caught_signal && child != (pid_t)-1) { fprintf(stderr, "\nSession terminated, killing shell\n"); kill(child, SIGTERM); } @@ -199,10 +199,12 @@ close: pamcleanup(PAM_SUCCESS); if (caught_signal) { - /* kill child */ - sleep(2); - kill(child, SIGKILL); - fprintf(stderr, " ...killed.\n"); + if (child != (pid_t)-1) { + /* kill child */ + sleep(2); + kill(child, SIGKILL); + fprintf(stderr, " ...killed.\n"); + } /* unblock cached signal and resend */ sigaction(SIGTERM, &oldact, NULL);