From 5b0532426881f774ee4588b50c66546ba7007a59 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 19 Apr 2019 00:51:06 +0200 Subject: [PATCH] More aggressive check for getrandom() and getentropy() usability In particular, they can be present, but not usable for a given compatibility level. This is especially expected on iOS and Android. --- configure.ac | 38 +++++++++++++++++++++++++++++++++++++- dist-build/ios.sh | 6 ++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8e8a9de1..e1fceada 100644 --- a/configure.ac +++ b/configure.ac @@ -794,8 +794,44 @@ dnl Checks for functions and headers AC_FUNC_ALLOCA AS_IF([test "x$EMSCRIPTEN" = "x"],[ - AC_CHECK_FUNCS([arc4random arc4random_buf getrandom getentropy]) + AC_CHECK_FUNCS([arc4random arc4random_buf]) AC_CHECK_FUNCS([mmap mlock madvise mprotect]) + + AC_MSG_CHECKING(for getrandom with a standard API) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_RANDOM_H +# include +#endif +]], [[ +unsigned char buf; +(void) getrandom((void *) &buf, 1U, 0U); + ]])], + [AC_MSG_RESULT(yes) + AC_CHECK_FUNCS([getrandom])], + [AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING(for getentropy with a standard API) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef HAVE_SYS_RANDOM_H +# include +#endif +]], [[ +unsigned char buf; +(void) getentropy((void *) &buf, 1U); + ]])], + [AC_MSG_RESULT(yes) + AC_CHECK_FUNCS([getentropy])], + [AC_MSG_RESULT(no) + ]) ]) AC_CHECK_FUNCS([posix_memalign getpid nanosleep]) AC_CHECK_FUNCS([memset_s explicit_bzero explicit_memset]) diff --git a/dist-build/ios.sh b/dist-build/ios.sh index 0575b090..2a2122ab 100755 --- a/dist-build/ios.sh +++ b/dist-build/ios.sh @@ -20,6 +20,12 @@ export XCODEDIR=$(xcode-select -p) export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"6.0.0"} export IOS_VERSION_MIN=${IOS_VERSION_MIN-"6.0.0"} +echo +echo "Warnings related to headers being present but not usable are due to functions" +echo "that didn't exist in the specified minimum iOS version level." +echo "They can be safely ignored." +echo + mkdir -p $SIMULATOR32_PREFIX $SIMULATOR64_PREFIX $IOS32_PREFIX $IOS32s_PREFIX $IOS64_PREFIX || exit 1 # Build for the simulator