Sync tty_present() with sudoers version.

This commit is contained in:
Todd C. Miller
2015-05-07 11:20:49 -06:00
parent 253008e62b
commit 166ee6879b

View File

@@ -333,10 +333,15 @@ tgetpass_handler(int s)
static bool static bool
tty_present(void) 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__)
debug_decl(tty_present, SUDO_DEBUG_UTIL)
debug_return_bool(user_details.tty != NULL);
#else
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|O_NOCTTY)) != -1)
close(fd); close(fd);
debug_return_bool(fd != -1); debug_return_bool(fd != -1);
#endif
} }