From 6fa2d21ba57b83c6148a8aa03a362ca9e771fe21 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 9 Dec 2016 13:21:37 +0100 Subject: m4/check-libc.m4: improve getentropy check - according to man.openbsd.org getentropy() is in unistd.h - according to macOS sierra's man it's in sys/random.h - since sys/random.h is does not exist for iOS and for linux, do not attempt to include it, rather redeclare the prototype - make sure that `./configure`: - uses getentropy() on macOS sierra - does not use getentropy() if compiling for 10.11 - does not use getentropy() if compiling for ios armv7 --- m4/check-libc.m4 | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'm4') diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 272ebfe..856495e 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 @@ -52,10 +52,27 @@ AC_CHECK_FUNCS([explicit_bzero getauxval]) AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include -#include +#include #ifdef __APPLE__ # include +# include + +# if (TARGET_OS_IPHONE || TARGET_OS_SIMULATOR) + +/* + * As of iOS 10.1, getentropy() as a system call is defined but is not + * declared in sys/random.h and submitting an App that links to getentropy() + * leads to the App store rejecting the App because: + * + * > The app references non-public symbols in $appname: _getentropy + * + * Disabling the check for getentropy() and thus enabling libressl own + * emulation of that fixes the issue. + */ +# error "As far as we know, getentropy() is not usable on iOS" + +# else /* * Before macOS 10.12 getentropy() was not available. In 10.12 however it @@ -78,24 +95,13 @@ AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [ # error "Running on Mac OSX 10.11 or earlier" # endif # endif -#endif -/* - * As of iOS 10.1, getentropy() as a system call is defined but is not - * declared in sys/random.h and submitting an App that links to getentropy() - * leads to the App store rejecting the App because: - * - * > The app references non-public symbols in $appname: _getentropy - * - * Disabling the check for getentropy() and thus enabling libressl own - * emulation of that fixes the issue. - */ -#if (defined TARGET_IPHONE_OS || defined TARGET_IPHONE_SIMULATOR) -# error "As far as we know, getentropy() is not usable on iOS" -#endif +# endif +#endif /* __APPLE__ */ ]], [[ - char buffer[1024]; - (void)getentropy(buffer, sizeof (buffer)); + extern int getentropy(void *, size_t); + char buffer; + (void)getentropy(&buffer, sizeof (buffer)); ]])], [ ac_cv_func_getentropy="yes" ], [ ac_cv_func_getentropy="no" -- cgit v1.2.3-55-g6feb