Now that we can determine the terminal even when file descriptors

are redirected we can check user_ttypath rather than opening
/dev/tty when enforcing requiretty.
This commit is contained in:
Todd C. Miller
2013-03-28 15:46:52 -04:00
parent 38dac1e0a4
commit 37b4b5d15e

View File

@@ -324,14 +324,10 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
} }
/* Bail if a tty is required and we don't have one. */ /* Bail if a tty is required and we don't have one. */
if (def_requiretty) { if (def_requiretty && user_ttypath == NULL) {
int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY); audit_failure(NewArgv, N_("no tty"));
if (fd == -1) { warningx(_("sorry, you must have a tty to run sudo"));
audit_failure(NewArgv, N_("no tty")); goto bad;
warningx(_("sorry, you must have a tty to run sudo"));
goto bad;
} else
(void) close(fd);
} }
/* /*