diff --git a/config.h.in b/config.h.in index d97c7ecce..98d42ad3a 100644 --- a/config.h.in +++ b/config.h.in @@ -928,9 +928,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PROCFS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_RANDOM_H - /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H diff --git a/configure b/configure index 4e48baac4..fdb22358e 100755 --- a/configure +++ b/configure @@ -17618,6 +17618,10 @@ then : fi + + # The glibc getentropy() emulation may fail on older kernels. + # We use our own getentropy() by default on Linux. + : ${ac_cv_func_getentropy='no'} ;; *-*-gnu*) # lockf() is broken on the Hurd @@ -21473,13 +21477,6 @@ if test "x$ac_cv_func_getentropy" = xyes then : printf "%s\n" "#define HAVE_GETENTROPY 1" >>confdefs.h - ac_fn_c_check_header_compile "$LINENO" "sys/random.h" "ac_cv_header_sys_random_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_random_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_RANDOM_H 1" >>confdefs.h - -fi - else $as_nop diff --git a/configure.ac b/configure.ac index b1f40d9f7..f8eb810ba 100644 --- a/configure.ac +++ b/configure.ac @@ -2047,6 +2047,10 @@ case "$host" in ]) # We call getrandom via syscall(3) in case it is not in libc AC_CHECK_HEADERS([linux/random.h]) + + # The glibc getentropy() emulation may fail on older kernels. + # We use our own getentropy() by default on Linux. + : ${ac_cv_func_getentropy='no'} ;; *-*-gnu*) # lockf() is broken on the Hurd @@ -2655,7 +2659,6 @@ AC_CHECK_FUNCS([arc4random], [ SUDO_APPEND_COMPAT_EXP(sudo_arc4random_uniform) # arc4random.c needs getentropy() AC_CHECK_FUNCS([getentropy], [ - AC_CHECK_HEADERS([sys/random.h]) ], [ AC_LIBOBJ(getentropy) SUDO_APPEND_COMPAT_EXP(sudo_getentropy) diff --git a/lib/util/arc4random.c b/lib/util/arc4random.c index 8e19555a8..0daa8f36a 100644 --- a/lib/util/arc4random.c +++ b/lib/util/arc4random.c @@ -34,10 +34,6 @@ #ifndef HAVE_ARC4RANDOM -#ifdef HAVE_SYS_RANDOM_H -# include -#endif - #include #include #include @@ -51,6 +47,7 @@ #endif #include "sudo_compat.h" +#include "sudo_fatal.h" #include "sudo_rand.h" #define KEYSTREAM_ONLY @@ -96,7 +93,7 @@ _rs_stir(void) unsigned char rnd[KEYSZ + IVSZ]; if (getentropy(rnd, sizeof rnd) == -1) - raise(SIGKILL); + sudo_fatal_nodebug("getentropy"); if (!rs_initialized) { rs_initialized = 1;