else
- ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "kp_eproc.e_tdev" "ac_cv_member_struct_kinfo_proc_kp_eproc_e_tdev" "
+ ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_tdev" "ac_cv_member_struct_kinfo_proc2_p_tdev" "
#include <sys/param.h>
#include <sys/sysctl.h>
"
-if test "x$ac_cv_member_struct_kinfo_proc_kp_eproc_e_tdev" = xyes; then :
+if test "x$ac_cv_member_struct_kinfo_proc2_p_tdev" = xyes; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV 1
+#define HAVE_STRUCT_KINFO_PROC2_P_TDEV 1
_ACEOF
_ACEOF
+else
+
+ ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "kp_eproc.e_tdev" "ac_cv_member_struct_kinfo_proc_kp_eproc_e_tdev" "
+ #include <sys/param.h>
+ #include <sys/sysctl.h>
+
+"
+if test "x$ac_cv_member_struct_kinfo_proc_kp_eproc_e_tdev" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV 1
+_ACEOF
+
+
+fi
+
+
fi
AC_CHECK_FUNCS(getutxid getutid, [break])
-AC_CHECK_FUNCS(sysctl, [AC_CHECK_MEMBERS([struct kinfo_proc.ki_tdev],
- [],
+AC_CHECK_FUNCS(sysctl, [AC_CHECK_MEMBERS([struct kinfo_proc.ki_tdev], [],
[
- AC_CHECK_MEMBERS([struct kinfo_proc.kp_eproc.e_tdev], [], [
- AC_CHECK_MEMBERS([struct kinfo_proc.p_tdev], [], [], [
+ AC_CHECK_MEMBERS([struct kinfo_proc2.p_tdev], [], [
+ AC_CHECK_MEMBERS([struct kinfo_proc.p_tdev], [], [
+ AC_CHECK_MEMBERS([struct kinfo_proc.kp_eproc.e_tdev], [], [], [
+ #include <sys/param.h>
+ #include <sys/sysctl.h>
+ ])
+ ], [
#include <sys/param.h>
#include <sys/sysctl.h>
])
#endif /* HAVE_UNISTD_H */
#include <errno.h>
#include <fcntl.h>
-#if defined(HAVE_STRUCT_KINFO_PROC_P_TDEV) || defined (HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV)
+#if defined(HAVE_STRUCT_KINFO_PROC_P_TDEV) || defined (HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV) || defined(HAVE_STRUCT_KINFO_PROC2_P_TDEV)
# include <sys/sysctl.h>
#elif defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV)
# include <sys/sysctl.h>
/*
* How to access the tty device number in struct kinfo_proc.
*/
-#if defined(HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV)
-# define sudo_kp_tdev kp_eproc.e_tdev
-# define sudo_kp_namelen 4
-#elif defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV)
-# define sudo_kp_tdev ki_tdev
-# define sudo_kp_namelen 4
+#if defined(HAVE_STRUCT_KINFO_PROC2_P_TDEV)
+# define SUDO_KERN_PROC KERN_PROC2
+# define sudo_kinfo_proc kinfo_proc2
+# define sudo_kp_tdev p_tdev
+# define sudo_kp_namelen 6
#elif defined(HAVE_STRUCT_KINFO_PROC_P_TDEV)
+# define SUDO_KERN_PROC KERN_PROC
+# define sudo_kinfo_proc kinfo_proc
# define sudo_kp_tdev p_tdev
# define sudo_kp_namelen 6
+#elif defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV)
+# define SUDO_KERN_PROC KERN_PROC
+# define sudo_kinfo_proc kinfo_proc
+# define sudo_kp_tdev ki_tdev
+# define sudo_kp_namelen 4
+#elif defined(HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV)
+# define SUDO_KERN_PROC KERN_PROC
+# define sudo_kinfo_proc kinfo_proc
+# define sudo_kp_tdev kp_eproc.e_tdev
+# define sudo_kp_namelen 4
#endif
#ifdef sudo_kp_tdev
get_process_ttyname()
{
char *tty = NULL;
- struct kinfo_proc *ki_proc = NULL;
+ struct sudo_kinfo_proc *ki_proc = NULL;
size_t size = sizeof(*ki_proc);
int i, mib[6], rc;
*/
for (i = 0; tty == NULL && i < 2; i++) {
mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
+ mib[1] = SUDO_KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = i ? (int)getppid() : (int)getpid();
mib[4] = sizeof(*ki_proc);
/* No tty for child, check the parent via /proc. */
ppid = getppid();
for (i = STDIN_FILENO; i < STDERR_FILENO && tty == NULL; i++) {
- snprintf(path, sizeof(path), "/proc/%d/fd/%d", ppid, i);
+ snprintf(path, sizeof(path), "/proc/%d/fd/%d", (int)ppid, i);
fd = open(path, O_RDONLY|O_NOCTTY, 0);
if (fd != -1) {
tty = ttyname(fd);