From de2da57776a6827d39a75f7e204c1e851031457f Mon Sep 17 00:00:00 2001 From: markm Date: Mon, 4 Jun 2001 20:59:49 +0000 Subject: In the same manner as getpass(3), block SIGINTR and SIGSTP while we are actually reading the line. --- contrib/libpam/libpam_misc/misc_conv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/libpam/libpam_misc/misc_conv.c b/contrib/libpam/libpam_misc/misc_conv.c index 1395b17..b0f62a2 100644 --- a/contrib/libpam/libpam_misc/misc_conv.c +++ b/contrib/libpam/libpam_misc/misc_conv.c @@ -135,6 +135,7 @@ static char *read_string(int echo, const char *prompt) char line[INPUTSIZE]; struct sigaction old_sig; int delay, nc, have_term=0; + sigset_t oset, nset; D(("called with echo='%s', prompt='%s'.", echo ? "ON":"OFF" , prompt)); @@ -150,6 +151,14 @@ static char *read_string(int echo, const char *prompt) term_tmp.c_lflag &= ~(ECHO); } have_term = 1; + /* + * note - blocking signals isn't necessarily the + * right thing, but we leave it for now. + */ + sigemptyset(&nset); + sigaddset(&nset, SIGINT); + sigaddset(&nset, SIGTSTP); + (void)_sigprocmask(SIG_BLOCK, &nset, &oset); } else if (!echo) { D(("")); @@ -204,8 +213,10 @@ static char *read_string(int echo, const char *prompt) } /* getting here implies that the timer expired */ - if (have_term) + if (have_term) { + (void)_sigprocmask(SIG_SETMASK, &oset, NULL); (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before); + } memset(line, 0, INPUTSIZE); /* clean up */ return NULL; -- cgit v1.1