]> granicus.if.org Git - sudo/commitdiff
Do not assume all Linux has linux/random.h.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Wed, 22 Aug 2018 21:12:11 +0000 (15:12 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Wed, 22 Aug 2018 21:12:11 +0000 (15:12 -0600)
Add missing sys/syscall.h include

config.h.in
configure
configure.ac
lib/util/getentropy.c

index 17b0681eab34c8ce1451e6986bdbb2f2c731f2a6..710af3ac487aae623a6302b022e77e023f3963aa 100644 (file)
 /* Define to 1 to enable Linux audit support. */
 #undef HAVE_LINUX_AUDIT
 
+/* Define to 1 if you have the <linux/random.h> header file. */
+#undef HAVE_LINUX_RANDOM_H
+
 /* Define to 1 if you have the `lockf' function. */
 #undef HAVE_LOCKF
 
index 21875393bb080c3c85598ddfc7c14f2e2e0ac684..af2560f0681ca403a1f84658208aed1ec77b7c48 100755 (executable)
--- 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
index 3d8b0484bd3744d1bc34067e9e38a216b6dd05df..04242579e9ad3dc69b414c5495aeaaa129961964 100644 (file)
@@ -2058,6 +2058,8 @@ case "$host" in
 #include <linux/seccomp.h>
 #include <linux/filter.h>
                ])
+               # 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
index 0d8aa133dafe1c87af95f180d5785b7dcef929c2..65a69ab5d0a464a862449e2ce669bac2b920f58e 100644 (file)
 #endif
 #include <sys/stat.h>
 #include <sys/time.h>
-#ifdef __linux__
-#include <linux/types.h>
-#include <linux/random.h>
+#ifdef HAVE_SYS_SYSCALL
+# include <sys/syscall.h>
+#endif
+#ifdef HAVE_LINUX_RANDOM_H
+# include <linux/types.h>
+# include <linux/random.h>
 #endif
 #include <errno.h>
 #include <fcntl.h>