aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimone Basso <bassosimone@gmail.com>2016-12-09 13:21:37 +0100
committerBrent Cook <bcook@openbsd.org>2017-01-07 07:21:07 -0600
commitc4ee1a6fca8ce7c46e90fe8dcf856131e03bcb0b (patch)
tree37d68711eb7b98a54782095ebb94688b4af54777
parentbd53433877bd2f81362c92c6fead4c374794cceb (diff)
downloadportable-c4ee1a6fca8ce7c46e90fe8dcf856131e03bcb0b.tar.gz
portable-c4ee1a6fca8ce7c46e90fe8dcf856131e03bcb0b.tar.bz2
portable-c4ee1a6fca8ce7c46e90fe8dcf856131e03bcb0b.zip
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
-rw-r--r--m4/check-libc.m440
1 files changed, 23 insertions, 17 deletions
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])
52AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [ 52AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [
53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
54#include <sys/types.h> 54#include <sys/types.h>
55#include <sys/random.h> 55#include <unistd.h>
56 56
57#ifdef __APPLE__ 57#ifdef __APPLE__
58# include <AvailabilityMacros.h> 58# include <AvailabilityMacros.h>
59# include <TargetConditionals.h>
60
61# if (TARGET_OS_IPHONE || TARGET_OS_SIMULATOR)
62
63/*
64 * As of iOS 10.1, getentropy() as a system call is defined but is not
65 * declared in sys/random.h and submitting an App that links to getentropy()
66 * leads to the App store rejecting the App because:
67 *
68 * > The app references non-public symbols in $appname: _getentropy
69 *
70 * Disabling the check for getentropy() and thus enabling libressl own
71 * emulation of that fixes the issue.
72 */
73# error "As far as we know, getentropy() is not usable on iOS"
74
75# else
59 76
60/* 77/*
61 * Before macOS 10.12 getentropy() was not available. In 10.12 however it 78 * 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, [
78# error "Running on Mac OSX 10.11 or earlier" 95# error "Running on Mac OSX 10.11 or earlier"
79# endif 96# endif
80# endif 97# endif
81#endif
82 98
83/* 99# endif
84 * As of iOS 10.1, getentropy() as a system call is defined but is not 100#endif /* __APPLE__ */
85 * declared in sys/random.h and submitting an App that links to getentropy()
86 * leads to the App store rejecting the App because:
87 *
88 * > The app references non-public symbols in $appname: _getentropy
89 *
90 * Disabling the check for getentropy() and thus enabling libressl own
91 * emulation of that fixes the issue.
92 */
93#if (defined TARGET_IPHONE_OS || defined TARGET_IPHONE_SIMULATOR)
94# error "As far as we know, getentropy() is not usable on iOS"
95#endif
96 ]], [[ 101 ]], [[
97 char buffer[1024]; 102 extern int getentropy(void *, size_t);
98 (void)getentropy(buffer, sizeof (buffer)); 103 char buffer;
104 (void)getentropy(&buffer, sizeof (buffer));
99]])], 105]])],
100 [ ac_cv_func_getentropy="yes" ], 106 [ ac_cv_func_getentropy="yes" ],
101 [ ac_cv_func_getentropy="no" 107 [ ac_cv_func_getentropy="no"