diff options
author | Simone Basso <bassosimone@gmail.com> | 2016-12-09 13:21:37 +0100 |
---|---|---|
committer | Simone Basso <bassosimone@gmail.com> | 2016-12-09 14:17:06 +0100 |
commit | 6fa2d21ba57b83c6148a8aa03a362ca9e771fe21 (patch) | |
tree | eee307c744632960800a9808b9652575bf335ea8 /m4 | |
parent | f8a9c71e793975e2d224cb01603bf814320545ab (diff) | |
download | portable-6fa2d21ba57b83c6148a8aa03a362ca9e771fe21.tar.gz portable-6fa2d21ba57b83c6148a8aa03a362ca9e771fe21.tar.bz2 portable-6fa2d21ba57b83c6148a8aa03a362ca9e771fe21.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
Diffstat (limited to 'm4')
-rw-r--r-- | m4/check-libc.m4 | 40 |
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]) | |||
52 | AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [ | 52 | AC_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" |