Use pstat() on HP-UX to determine the tty device.
This commit is contained in:
@@ -430,6 +430,9 @@
|
||||
/* Define to 1 if you have the <project.h> header file. */
|
||||
#undef HAVE_PROJECT_H
|
||||
|
||||
/* Define to 1 if you have the `pstat_getproc' function. */
|
||||
#undef HAVE_PSTAT_GETPROC
|
||||
|
||||
/* Define to 1 if you have the <pty.h> header file. */
|
||||
#undef HAVE_PTY_H
|
||||
|
||||
|
11
configure
vendored
11
configure
vendored
@@ -14181,6 +14181,17 @@ $as_echo "$sudo_cv_var_daportable" >&6; }
|
||||
test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
|
||||
;;
|
||||
esac
|
||||
for ac_func in pstat_getproc
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "pstat_getproc" "ac_cv_func_pstat_getproc"
|
||||
if test "x$ac_cv_func_pstat_getproc" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_PSTAT_GETPROC 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
;;
|
||||
*-dec-osf*)
|
||||
# ignore envariables wrt dynamic lib path
|
||||
|
@@ -1742,6 +1742,7 @@ case "$host" in
|
||||
test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
|
||||
;;
|
||||
esac
|
||||
AC_CHECK_FUNCS(pstat_getproc)
|
||||
;;
|
||||
*-dec-osf*)
|
||||
# ignore envariables wrt dynamic lib path
|
||||
|
@@ -82,6 +82,10 @@
|
||||
#elif defined(HAVE_SYS_PROCFS_H)
|
||||
# include <sys/procfs.h>
|
||||
#endif
|
||||
#ifdef HAVE_PSTAT_GETPROC
|
||||
# include <sys/param.h>
|
||||
# include <sys/pstat.h>
|
||||
#endif
|
||||
|
||||
#include "sudo.h"
|
||||
|
||||
@@ -156,7 +160,7 @@ sudo_ttyname_dev(dev_t tdev)
|
||||
|
||||
debug_return_str(estrdup(tty));
|
||||
}
|
||||
#elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(__linux__)
|
||||
#elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
|
||||
/*
|
||||
* Devices to search before doing a breadth-first scan.
|
||||
*/
|
||||
@@ -335,7 +339,6 @@ sudo_ttyname_dev(dev_t rdev)
|
||||
* Return a string from ttyname() containing the tty to which the process is
|
||||
* attached or NULL if there is no tty associated with the process (or its
|
||||
* parent). First tries sysctl using the current pid, then the parent's pid.
|
||||
* Falls back on ttyname of std{in,out,err} if that fails.
|
||||
*/
|
||||
char *
|
||||
get_process_ttyname(void)
|
||||
@@ -385,7 +388,6 @@ get_process_ttyname(void)
|
||||
* Return a string from ttyname() containing the tty to which the process is
|
||||
* attached or NULL if there is no tty associated with the process (or its
|
||||
* parent). First tries /proc/pid/psinfo, then /proc/ppid/psinfo.
|
||||
* Falls back on ttyname of std{in,out,err} if that fails.
|
||||
*/
|
||||
char *
|
||||
get_process_ttyname(void)
|
||||
@@ -416,7 +418,6 @@ get_process_ttyname(void)
|
||||
* Return a string from ttyname() containing the tty to which the process is
|
||||
* attached or NULL if there is no tty associated with the process (or its
|
||||
* parent). First tries field 7 in /proc/pid/stat, then /proc/ppid/stat.
|
||||
* Falls back on ttyname of std{in,out,err} if that fails.
|
||||
*/
|
||||
char *
|
||||
get_process_ttyname(void)
|
||||
@@ -457,6 +458,32 @@ get_process_ttyname(void)
|
||||
|
||||
debug_return_str(tty);
|
||||
}
|
||||
#elif HAVE_PSTAT_GETPROC
|
||||
/*
|
||||
* Return a string from ttyname() containing the tty to which the process is
|
||||
* attached or NULL if there is no tty associated with the process (or its
|
||||
* parent).
|
||||
*/
|
||||
char *
|
||||
get_process_ttyname(void)
|
||||
{
|
||||
struct pst_status pstat;
|
||||
char *tty = NULL;
|
||||
int i;
|
||||
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
|
||||
|
||||
/* Try to determine the tty from psdev in struct pst_status. */
|
||||
for (i = 0; tty == NULL && i < 2; i++) {
|
||||
const int pid = i ? (int)getppid() : (int)getpid();
|
||||
if (pstat_getproc(&pstat, sizeof(pstat), 0, pid) != -1) {
|
||||
if (pstat.pst_term.psd_major != -1 && pstat.pst_term.psd_minor != -1) {
|
||||
tty = sudo_ttyname_dev(makedev(pstat.pst_term.psd_major,
|
||||
pstat.pst_term.psd_minor));
|
||||
}
|
||||
}
|
||||
}
|
||||
debug_return_str(tty);
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* Return a string from ttyname() containing the tty to which the process is
|
||||
|
Reference in New Issue
Block a user