From: Todd C. Miller Date: Wed, 22 Aug 2018 21:12:11 +0000 (-0600) Subject: Do not assume all Linux has linux/random.h. X-Git-Tag: SUDO_1_8_25^2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d876602dbf0f9d987f83b175e51144455a3b28f0;p=sudo Do not assume all Linux has linux/random.h. Add missing sys/syscall.h include --- diff --git a/config.h.in b/config.h.in index 17b0681ea..710af3ac4 100644 --- a/config.h.in +++ b/config.h.in @@ -467,6 +467,9 @@ /* Define to 1 to enable Linux audit support. */ #undef HAVE_LINUX_AUDIT +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_RANDOM_H + /* Define to 1 if you have the `lockf' function. */ #undef HAVE_LOCKF diff --git a/configure b/configure index 21875393b..af2560f06 100755 --- a/configure +++ b/configure @@ -15953,6 +15953,19 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SECCOMP_SET_MODE_FILTER $ac_have_decl _ACEOF + # We call getrandom via syscall(3) in case it is not in libc + for ac_header in linux/random.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "linux/random.h" "ac_cv_header_linux_random_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_random_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_RANDOM_H 1 +_ACEOF + +fi + +done + ;; *-*-gnu*) # lockf() is broken on the Hurd diff --git a/configure.ac b/configure.ac index 3d8b0484b..04242579e 100644 --- a/configure.ac +++ b/configure.ac @@ -2058,6 +2058,8 @@ case "$host" in #include #include ]) + # We call getrandom via syscall(3) in case it is not in libc + AC_CHECK_HEADERS([linux/random.h]) ;; *-*-gnu*) # lockf() is broken on the Hurd diff --git a/lib/util/getentropy.c b/lib/util/getentropy.c index 0d8aa133d..65a69ab5d 100644 --- a/lib/util/getentropy.c +++ b/lib/util/getentropy.c @@ -35,9 +35,12 @@ #endif #include #include -#ifdef __linux__ -#include -#include +#ifdef HAVE_SYS_SYSCALL +# include +#endif +#ifdef HAVE_LINUX_RANDOM_H +# include +# include #endif #include #include