O_NOCTTY has no effect when opening /dev/tty as the open can only
succeed if there is already a controlling tty.
This commit is contained in:
@@ -1298,7 +1298,7 @@ tty_present(void)
|
|||||||
#if defined(HAVE_STRUCT_KINFO_PROC2_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV) || defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
|
#if defined(HAVE_STRUCT_KINFO_PROC2_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV) || defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
|
||||||
return user_ttypath != NULL;
|
return user_ttypath != NULL;
|
||||||
#else
|
#else
|
||||||
int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY);
|
int fd = open(_PATH_TTY, O_RDWR);
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
return fd != -1;
|
return fd != -1;
|
||||||
|
@@ -562,7 +562,7 @@ dispatch_signal(struct sudo_event_base *evbase, pid_t child,
|
|||||||
sigaction_t sa, osa;
|
sigaction_t sa, osa;
|
||||||
pid_t saved_pgrp = -1;
|
pid_t saved_pgrp = -1;
|
||||||
int signo = WSTOPSIG(status);
|
int signo = WSTOPSIG(status);
|
||||||
int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
|
int fd = open(_PATH_TTY, O_RDWR);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
saved_pgrp = tcgetpgrp(fd);
|
saved_pgrp = tcgetpgrp(fd);
|
||||||
if (saved_pgrp == -1) {
|
if (saved_pgrp == -1) {
|
||||||
|
@@ -181,7 +181,7 @@ pty_setup(uid_t uid, const char *tty, const char *utmp_user)
|
|||||||
{
|
{
|
||||||
debug_decl(pty_setup, SUDO_DEBUG_EXEC);
|
debug_decl(pty_setup, SUDO_DEBUG_EXEC);
|
||||||
|
|
||||||
io_fds[SFD_USERTTY] = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
|
io_fds[SFD_USERTTY] = open(_PATH_TTY, O_RDWR);
|
||||||
if (io_fds[SFD_USERTTY] != -1) {
|
if (io_fds[SFD_USERTTY] != -1) {
|
||||||
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
|
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
|
||||||
slavename, sizeof(slavename), uid))
|
slavename, sizeof(slavename), uid))
|
||||||
|
@@ -506,7 +506,7 @@ get_user_info(struct user_details *ud)
|
|||||||
ud->ppid = getppid();
|
ud->ppid = getppid();
|
||||||
ud->pgid = getpgid(0);
|
ud->pgid = getpgid(0);
|
||||||
ud->tcpgid = -1;
|
ud->tcpgid = -1;
|
||||||
fd = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
|
fd = open(_PATH_TTY, O_RDWR);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
ud->tcpgid = tcgetpgrp(fd);
|
ud->tcpgid = tcgetpgrp(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@@ -125,7 +125,7 @@ restart:
|
|||||||
need_restart = 0;
|
need_restart = 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)) == -1) {
|
||||||
input = STDIN_FILENO;
|
input = STDIN_FILENO;
|
||||||
output = STDERR_FILENO;
|
output = STDERR_FILENO;
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ tty_present(void)
|
|||||||
int fd;
|
int fd;
|
||||||
debug_decl(tty_present, SUDO_DEBUG_UTIL)
|
debug_decl(tty_present, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
if ((fd = open(_PATH_TTY, O_RDWR|O_NOCTTY)) != -1)
|
if ((fd = open(_PATH_TTY, O_RDWR)) != -1)
|
||||||
close(fd);
|
close(fd);
|
||||||
debug_return_bool(fd != -1);
|
debug_return_bool(fd != -1);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user