version 1.11, 2007/07/26 16:10:16 |
version 1.12, 2007/10/17 04:26:05 |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
__unused static const char rcsid[] = "$Sudo: tgetpass.c,v 1.111.2.2 2007/06/12 01:26:35 millert Exp $"; |
__unused static const char rcsid[] = "$Sudo: tgetpass.c,v 1.111.2.4 2007/10/08 16:01:10 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
#ifndef TCSASOFT |
#ifndef TCSASOFT |
|
|
|
|
(void) fflush(stdout); |
(void) fflush(stdout); |
restart: |
restart: |
|
signo = 0; |
|
pass = NULL; |
|
save_errno = 0; |
/* Open /dev/tty for reading/writing if possible else use stdin/stderr. */ |
/* Open /dev/tty for reading/writing if possible else use stdin/stderr. */ |
if (ISSET(flags, TGP_STDIN) || |
if (ISSET(flags, TGP_STDIN) || |
(input = output = open(_PATH_TTY, O_RDWR|O_NOCTTY)) == -1) { |
(input = output = open(_PATH_TTY, O_RDWR|O_NOCTTY)) == -1) { |
|
|
memset(&oterm, 0, sizeof(oterm)); |
memset(&oterm, 0, sizeof(oterm)); |
} |
} |
|
|
if (prompt) |
/* No output if we are already backgrounded. */ |
(void) write(output, prompt, strlen(prompt)); |
if (signo != SIGTTOU && signo != SIGTTIN) { |
|
if (prompt) |
|
(void) write(output, prompt, strlen(prompt)); |
|
|
if (timeout > 0) |
if (timeout > 0) |
alarm(timeout); |
alarm(timeout); |
pass = getln(input, buf, sizeof(buf)); |
pass = getln(input, buf, sizeof(buf)); |
alarm(0); |
alarm(0); |
save_errno = errno; |
save_errno = errno; |
|
|
if (!ISSET(term.tflags, ECHO)) |
if (!ISSET(term.tflags, ECHO)) |
(void) write(output, "\n", 1); |
(void) write(output, "\n", 1); |
|
} |
|
|
/* Restore old tty settings and signals. */ |
/* Restore old tty settings and signals. */ |
if (memcmp(&term, &oterm, sizeof(term)) != 0) |
if (memcmp(&term, &oterm, sizeof(term)) != 0) |
|
|
case SIGTSTP: |
case SIGTSTP: |
case SIGTTIN: |
case SIGTTIN: |
case SIGTTOU: |
case SIGTTOU: |
signo = 0; |
|
goto restart; |
goto restart; |
} |
} |
} |
} |
|
|
errno = save_errno; |
if (save_errno) |
|
errno = save_errno; |
return(pass); |
return(pass); |
} |
} |
|
|