2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Add support for the struct kinfo_proc on Dragonfly BSD.

This commit is contained in:
Todd C. Miller
2023-01-19 13:22:32 -07:00
parent d409ba67c6
commit 9ddae66818
6 changed files with 126 additions and 60 deletions

View File

@@ -472,6 +472,9 @@
/* Define to 1 if your system has a 4.4BSD-style kinfo_proc struct. */
#undef HAVE_KINFO_PROC_44BSD
/* Define to 1 if your system has a Dragonfly-style kinfo_proc struct. */
#undef HAVE_KINFO_PROC_DFLY
/* Define to 1 if your system has a FreeBSD-style kinfo_proc struct. */
#undef HAVE_KINFO_PROC_FREEBSD

95
configure vendored
View File

@@ -22410,70 +22410,96 @@ do :
if test "x$ac_cv_func_sysctl" = xyes
then :
printf "%s\n" "#define HAVE_SYSCTL 1" >>confdefs.h
ac_fn_c_check_func "$LINENO" "devname" "ac_cv_func_devname"
ac_fn_c_check_func "$LINENO" "devname" "ac_cv_func_devname"
if test "x$ac_cv_func_devname" = xyes
then :
printf "%s\n" "#define HAVE_DEVNAME 1" >>confdefs.h
fi
# Check for the various flavors of kinfo_proc
found=false
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "ki_structsize" "ac_cv_member_struct_kinfo_proc_ki_structsize" "
# include <sys/param.h>
# include <sys/sysctl.h>
# include <sys/user.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
"
if test "x$ac_cv_member_struct_kinfo_proc_ki_structsize" = xyes
then :
printf "%s\n" "#define HAVE_KINFO_PROC_FREEBSD 1" >>confdefs.h
else case e in #(
e)
printf "%s\n" "#define HAVE_KINFO_PROC_FREEBSD 1" >>confdefs.h
found=true
fi
if test "$found" = "false"; then
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "kp_paddr" "ac_cv_member_struct_kinfo_proc_kp_paddr" "
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
"
if test "x$ac_cv_member_struct_kinfo_proc_kp_paddr" = xyes
then :
printf "%s\n" "#define HAVE_KINFO_PROC_DFLY 1" >>confdefs.h
found=true
fi
fi
if test "$found" = "false"; then
ac_fn_c_check_member "$LINENO" "struct kinfo_proc2" "p_paddr" "ac_cv_member_struct_kinfo_proc2_p_paddr" "
# include <sys/param.h>
# include <sys/sysctl.h>
#include <sys/param.h>
#include <sys/sysctl.h>
"
if test "x$ac_cv_member_struct_kinfo_proc2_p_paddr" = xyes
then :
printf "%s\n" "#define HAVE_KINFO_PROC2_NETBSD 1" >>confdefs.h
else case e in #(
e)
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "p_paddr" "ac_cv_member_struct_kinfo_proc_p_paddr" "
# include <sys/param.h>
# include <sys/sysctl.h>
printf "%s\n" "#define HAVE_KINFO_PROC2_NETBSD 1" >>confdefs.h
found=true
fi
fi
if test "$found" = "false"; then
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "p_paddr" "ac_cv_member_struct_kinfo_proc_p_paddr" "
#include <sys/param.h>
#include <sys/sysctl.h>
"
if test "x$ac_cv_member_struct_kinfo_proc_p_paddr" = xyes
then :
printf "%s\n" "#define HAVE_KINFO_PROC_OPENBSD 1" >>confdefs.h
else case e in #(
e)
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "kp_proc" "ac_cv_member_struct_kinfo_proc_kp_proc" "
# include <sys/param.h>
# include <sys/sysctl.h>
printf "%s\n" "#define HAVE_KINFO_PROC_OPENBSD 1" >>confdefs.h
found=true
fi
fi
if test "$found" = "false"; then
ac_fn_c_check_member "$LINENO" "struct kinfo_proc" "kp_proc" "ac_cv_member_struct_kinfo_proc_kp_proc" "
#include <sys/param.h>
#include <sys/sysctl.h>
"
if test "x$ac_cv_member_struct_kinfo_proc_kp_proc" = xyes
then :
printf "%s\n" "#define HAVE_KINFO_PROC_44BSD 1" >>confdefs.h
printf "%s\n" "#define HAVE_KINFO_PROC_44BSD 1" >>confdefs.h
found=true
fi
;;
esac
fi
;;
esac
fi
;;
esac
fi
fi
fi
@@ -37305,5 +37331,6 @@ fi

View File

@@ -2730,29 +2730,55 @@ if test "$utmp_style" = "LEGACY"; then
AC_CHECK_FUNCS([getttyent ttyslot], [break])
fi
AC_CHECK_FUNCS([sysctl], [AC_CHECK_FUNCS([devname])
AC_CHECK_MEMBER([struct kinfo_proc.ki_structsize], [AC_DEFINE(HAVE_KINFO_PROC_FREEBSD)], [
AC_CHECK_MEMBER([struct kinfo_proc2.p_paddr], [AC_DEFINE(HAVE_KINFO_PROC2_NETBSD)], [
AC_CHECK_MEMBER([struct kinfo_proc.p_paddr], [AC_DEFINE(HAVE_KINFO_PROC_OPENBSD)], [
AC_CHECK_MEMBER([struct kinfo_proc.kp_proc], [AC_DEFINE(HAVE_KINFO_PROC_44BSD)], [], [
# include <sys/param.h>
# include <sys/sysctl.h>
])
], [
# include <sys/param.h>
# include <sys/sysctl.h>
])
],
[
# include <sys/param.h>
# include <sys/sysctl.h>
])
],
[
# include <sys/param.h>
# include <sys/sysctl.h>
# include <sys/user.h>
AC_CHECK_FUNCS([sysctl], [
AC_CHECK_FUNCS([devname])
# Check for the various flavors of kinfo_proc
found=false
AC_CHECK_MEMBER([struct kinfo_proc.ki_structsize], [
AC_DEFINE(HAVE_KINFO_PROC_FREEBSD)
found=true
], [], [
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
])
if test "$found" = "false"; then
AC_CHECK_MEMBER([struct kinfo_proc.kp_paddr], [
AC_DEFINE(HAVE_KINFO_PROC_DFLY)
found=true
], [], [
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
])
fi
if test "$found" = "false"; then
AC_CHECK_MEMBER([struct kinfo_proc2.p_paddr], [
AC_DEFINE(HAVE_KINFO_PROC2_NETBSD)
found=true
], [], [
#include <sys/param.h>
#include <sys/sysctl.h>
])
fi
if test "$found" = "false"; then
AC_CHECK_MEMBER([struct kinfo_proc.p_paddr], [
AC_DEFINE(HAVE_KINFO_PROC_OPENBSD)
found=true
], [], [
#include <sys/param.h>
#include <sys/sysctl.h>
])
fi
if test "$found" = "false"; then
AC_CHECK_MEMBER([struct kinfo_proc.kp_proc], [
AC_DEFINE(HAVE_KINFO_PROC_44BSD)
found=true
], [], [
#include <sys/param.h>
#include <sys/sysctl.h>
])
fi
])
AC_CHECK_FUNCS([openpty], [AC_CHECK_HEADERS([libutil.h util.h pty.h], [break])], [
@@ -4647,6 +4673,7 @@ AH_TEMPLATE(HAVE_STRNLEN, [Define to 1 if you have the 'strnlen' function.])
AH_TEMPLATE(PAM_SUN_CODEBASE, [Define to 1 if your system uses a Solaris-derived PAM and not Linux-PAM or OpenPAM.])
AH_TEMPLATE(HAVE_KINFO_PROC_44BSD, [Define to 1 if your system has a 4.4BSD-style kinfo_proc struct.])
AH_TEMPLATE(HAVE_KINFO_PROC_FREEBSD, [Define to 1 if your system has a FreeBSD-style kinfo_proc struct.])
AH_TEMPLATE(HAVE_KINFO_PROC_DFLY, [Define to 1 if your system has a Dragonfly-style kinfo_proc struct.])
AH_TEMPLATE(HAVE_KINFO_PROC2_NETBSD, [Define to 1 if your system has a NetBSD-style kinfo_proc2 struct.])
AH_TEMPLATE(HAVE_KINFO_PROC_OPENBSD, [Define to 1 if your system has an OpenBSD-style kinfo_proc struct.])
AH_TEMPLATE(HAVE_OPENSSL, [Define to 1 if you are using OpenSSL's TLS and sha2 functions.])

View File

@@ -33,7 +33,7 @@
#include <sys/stat.h>
#if defined(HAVE_KINFO_PROC_44BSD) || defined (HAVE_KINFO_PROC_OPENBSD) || defined(HAVE_KINFO_PROC2_NETBSD)
# include <sys/sysctl.h>
#elif defined(HAVE_KINFO_PROC_FREEBSD)
#elif defined(HAVE_KINFO_PROC_FREEBSD) || defined(HAVE_KINFO_PROC_DFLY)
# include <sys/param.h>
# include <sys/sysctl.h>
# include <sys/user.h>
@@ -70,7 +70,7 @@
# define SUDO_KERN_PROC KERN_PROC
# define sudo_kinfo_proc kinfo_proc
# define sudo_kp_namelen 6
#elif defined(HAVE_KINFO_PROC_FREEBSD) || defined(HAVE_KINFO_PROC_44BSD)
#elif defined(HAVE_KINFO_PROC_FREEBSD) || defined(HAVE_KINFO_PROC_DFLY) || defined(HAVE_KINFO_PROC_44BSD)
# define SUDO_KERN_PROC KERN_PROC
# define sudo_kinfo_proc kinfo_proc
# define sudo_kp_namelen 4
@@ -113,8 +113,11 @@ get_starttime(pid_t pid, struct timespec *starttime)
}
if (rc != -1) {
#if defined(HAVE_KINFO_PROC_FREEBSD)
/* FreeBSD and Dragonfly */
/* FreeBSD. */
TIMEVAL_TO_TIMESPEC(&ki_proc->ki_start, starttime);
#elif defined(HAVE_KINFO_PROC_DFLY)
/* Dragonfly. */
TIMEVAL_TO_TIMESPEC(&ki_proc->kp_start, starttime);
#elif defined(HAVE_KINFO_PROC_44BSD)
/* 4.4BSD and macOS */
TIMEVAL_TO_TIMESPEC(&ki_proc->kp_proc.p_starttime, starttime);

View File

@@ -91,6 +91,7 @@ main(int argc, char *argv[])
#if defined(HAVE_KINFO_PROC2_NETBSD) || \
defined(HAVE_KINFO_PROC_OPENBSD) || \
defined(HAVE_KINFO_PROC_FREEBSD) || \
defined(HAVE_KINFO_PROC_DFLY) || \
defined(HAVE_KINFO_PROC_44BSD) || \
defined(HAVE__TTYNAME_DEV) || defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || \
defined(HAVE_PSTAT_GETPROC) || defined(__linux__)

View File

@@ -46,7 +46,7 @@
#include <dirent.h>
#if defined(HAVE_KINFO_PROC2_NETBSD) || defined (HAVE_KINFO_PROC_OPENBSD) || defined(HAVE_KINFO_PROC_44BSD)
# include <sys/sysctl.h>
#elif defined(HAVE_KINFO_PROC_FREEBSD)
#elif defined(HAVE_KINFO_PROC_FREEBSD) || defined(HAVE_KINFO_PROC_DFLY)
# include <sys/param.h>
# include <sys/sysctl.h>
# include <sys/user.h>
@@ -80,6 +80,11 @@
# define sudo_kinfo_proc kinfo_proc
# define sudo_kp_tdev ki_tdev
# define sudo_kp_namelen 4
#elif defined(HAVE_KINFO_PROC_DFLY)
# define SUDO_KERN_PROC KERN_PROC
# define sudo_kinfo_proc kinfo_proc
# define sudo_kp_tdev kp_tdev
# define sudo_kp_namelen 4
#elif defined(HAVE_KINFO_PROC_44BSD)
# define SUDO_KERN_PROC KERN_PROC
# define sudo_kinfo_proc kinfo_proc