summaryrefslogtreecommitdiff
path: root/usr.bin/sudo/tgetpass.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2007-10-17 04:26:06 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2007-10-17 04:26:06 +0000
commitebdb26af86961f3b0bcce472302c01810af12155 (patch)
treeb0078ca6912ac548b07cfeb03aaed9d737f22aa9 /usr.bin/sudo/tgetpass.c
parentd8af0394f23725d01d6ee24975c1d089c023cd4e (diff)
Update to sudo 1.6.9p6
Diffstat (limited to 'usr.bin/sudo/tgetpass.c')
-rw-r--r--usr.bin/sudo/tgetpass.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/usr.bin/sudo/tgetpass.c b/usr.bin/sudo/tgetpass.c
index 2fec0d819f9..6e356cd6d7a 100644
--- a/usr.bin/sudo/tgetpass.c
+++ b/usr.bin/sudo/tgetpass.c
@@ -70,7 +70,7 @@
#include "sudo.h"
#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 */
#ifndef TCSASOFT
@@ -135,6 +135,9 @@ tgetpass(prompt, timeout, flags)
(void) fflush(stdout);
restart:
+ signo = 0;
+ pass = NULL;
+ save_errno = 0;
/* Open /dev/tty for reading/writing if possible else use stdin/stderr. */
if (ISSET(flags, TGP_STDIN) ||
(input = output = open(_PATH_TTY, O_RDWR|O_NOCTTY)) == -1) {
@@ -172,17 +175,20 @@ restart:
memset(&oterm, 0, sizeof(oterm));
}
- if (prompt)
- (void) write(output, prompt, strlen(prompt));
+ /* No output if we are already backgrounded. */
+ if (signo != SIGTTOU && signo != SIGTTIN) {
+ if (prompt)
+ (void) write(output, prompt, strlen(prompt));
- if (timeout > 0)
- alarm(timeout);
- pass = getln(input, buf, sizeof(buf));
- alarm(0);
- save_errno = errno;
+ if (timeout > 0)
+ alarm(timeout);
+ pass = getln(input, buf, sizeof(buf));
+ alarm(0);
+ save_errno = errno;
- if (!ISSET(term.tflags, ECHO))
- (void) write(output, "\n", 1);
+ if (!ISSET(term.tflags, ECHO))
+ (void) write(output, "\n", 1);
+ }
/* Restore old tty settings and signals. */
if (memcmp(&term, &oterm, sizeof(term)) != 0)
@@ -208,12 +214,12 @@ restart:
case SIGTSTP:
case SIGTTIN:
case SIGTTOU:
- signo = 0;
goto restart;
}
}
- errno = save_errno;
+ if (save_errno)
+ errno = save_errno;
return(pass);
}