diff options
author | Simone Basso <bassosimone@gmail.com> | 2016-12-10 20:58:04 +0100 |
---|---|---|
committer | Simone Basso <bassosimone@gmail.com> | 2016-12-10 20:58:04 +0100 |
commit | a206997ad9b7ebd4bb383b10212f02e26f924e56 (patch) | |
tree | 6162707ac972ff2d4092d6242e1b55087c85b5b3 /m4/check-libc.m4 | |
parent | 6fa2d21ba57b83c6148a8aa03a362ca9e771fe21 (diff) | |
download | portable-a206997ad9b7ebd4bb383b10212f02e26f924e56.tar.gz portable-a206997ad9b7ebd4bb383b10212f02e26f924e56.tar.bz2 portable-a206997ad9b7ebd4bb383b10212f02e26f924e56.zip |
Sync getentropy() checks with use-builtin-arc4random checks
Without this, we actually fail to build a library that includes the
bultin getentropy when compiling for 10.11 on 10.12.
Diffstat (limited to 'm4/check-libc.m4')
-rw-r--r-- | m4/check-libc.m4 | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 856495e..466a70e 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 | |||
@@ -54,52 +54,37 @@ AC_CACHE_CHECK([for getentropy], ac_cv_func_getentropy, [ | |||
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <unistd.h> | 55 | #include <unistd.h> |
56 | 56 | ||
57 | #ifdef __APPLE__ | ||
58 | # include <AvailabilityMacros.h> | ||
59 | # include <TargetConditionals.h> | ||
60 | |||
61 | # if (TARGET_OS_IPHONE || TARGET_OS_SIMULATOR) | ||
62 | |||
63 | /* | 57 | /* |
64 | * As of iOS 10.1, getentropy() as a system call is defined but is not | 58 | * Explanation: |
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 | * | 59 | * |
68 | * > The app references non-public symbols in $appname: _getentropy | 60 | * - iOS <= 10.1 fails because of missing sys/random.h |
69 | * | 61 | * |
70 | * Disabling the check for getentropy() and thus enabling libressl own | 62 | * - in macOS 10.12 getentropy is not tagged as introduced in |
71 | * emulation of that fixes the issue. | 63 | * 10.12 so we cannot use it for target < 10.12 |
72 | */ | 64 | */ |
73 | # error "As far as we know, getentropy() is not usable on iOS" | 65 | #ifdef __APPLE__ |
66 | # include <AvailabilityMacros.h> | ||
67 | # include <TargetConditionals.h> | ||
74 | 68 | ||
69 | # if (TARGET_OS_IPHONE || TARGET_OS_SIMULATOR) | ||
70 | # include <sys/random.h> /* Not available as of iOS <= 10.1 */ | ||
75 | # else | 71 | # else |
76 | 72 | ||
77 | /* | 73 | # include <sys/random.h> /* Pre 10.12 systems should die here */ |
78 | * Before macOS 10.12 getentropy() was not available. In 10.12 however it | 74 | |
79 | * seems to be not marked for retro-compatibility and thus we cannot cross | 75 | /* Based on: https://gitweb.torproject.org/tor.git/commit/?id=16fcbd21 */ |
80 | * compile targeting, e.g., 10.12 unless we disable getentropy(). | ||
81 | * | ||
82 | * To test, | ||
83 | * | ||
84 | * export CFLAGS="-mmacosx-version-min=10.11" | ||
85 | * ./configure | ||
86 | * # ensure that getentropy() is not found | ||
87 | * | ||
88 | * Based on: https://gitweb.torproject.org/tor.git/commit/?id=https://gitweb.torproject.org/tor.git/commit/?id=16fcbd21c963a9a65bf55024680c8323c8b7175d | ||
89 | */ | ||
90 | # ifndef MAC_OS_X_VERSION_10_12 | 76 | # ifndef MAC_OS_X_VERSION_10_12 |
91 | # define MAC_OS_X_VERSION_10_12 101200 | 77 | # define MAC_OS_X_VERSION_10_12 101200 /* Robustness */ |
92 | # endif | 78 | # endif |
93 | # if defined(MAC_OS_X_VERSION_MIN_REQUIRED) | 79 | # if defined(MAC_OS_X_VERSION_MIN_REQUIRED) |
94 | # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 | 80 | # if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 |
95 | # error "Running on Mac OSX 10.11 or earlier" | 81 | # error "Targeting on Mac OSX 10.11 or earlier" |
96 | # endif | 82 | # endif |
97 | # endif | 83 | # endif |
98 | 84 | ||
99 | # endif | 85 | # endif |
100 | #endif /* __APPLE__ */ | 86 | #endif /* __APPLE__ */ |
101 | ]], [[ | 87 | ]], [[ |
102 | extern int getentropy(void *, size_t); | ||
103 | char buffer; | 88 | char buffer; |
104 | (void)getentropy(&buffer, sizeof (buffer)); | 89 | (void)getentropy(&buffer, sizeof (buffer)); |
105 | ]])], | 90 | ]])], |