Even if neither stdin nor stdout are ttys we may still have /dev/tty
available to us.
This commit is contained in:
4
check.c
4
check.c
@@ -109,9 +109,9 @@ check_user(validated, interactive)
|
||||
if (user_askpass == NULL)
|
||||
log_error(NO_MAIL,
|
||||
"no askpass program specified, try setting SUDO_ASKPASS");
|
||||
} else {
|
||||
} else if (!ISSET(tgetpass_flags, TGP_STDIN)) {
|
||||
/* If no tty but DISPLAY is set, use askpass if we have it. */
|
||||
if (!user_ttypath && !ISSET(tgetpass_flags, TGP_STDIN)) {
|
||||
if (!user_ttypath && !tty_present()) {
|
||||
if (user_askpass && user_display && *user_display != '\0') {
|
||||
SET(tgetpass_flags, TGP_ASKPASS);
|
||||
} else if (!def_visiblepw) {
|
||||
|
1
sudo.h
1
sudo.h
@@ -240,6 +240,7 @@ int mkstemp __P((char *));
|
||||
char *sudo_goodpath __P((const char *, struct stat *));
|
||||
char *tgetpass __P((const char *, int, int));
|
||||
int find_path __P((char *, char **, struct stat *, char *));
|
||||
int tty_present __P((void));
|
||||
void check_user __P((int, int));
|
||||
void verify_user __P((struct passwd *, char *));
|
||||
#ifdef HAVE_LDAP
|
||||
|
10
tgetpass.c
10
tgetpass.c
@@ -309,3 +309,13 @@ handler(s)
|
||||
if (s != SIGALRM)
|
||||
signo = s;
|
||||
}
|
||||
|
||||
int
|
||||
tty_present()
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(_PATH_TTY, O_RDWR|O_NOCTTY)) != -1)
|
||||
close(fd);
|
||||
return(fd != -1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user