diff options
author | Thomas Haller <thaller@redhat.com> | 2017-10-11 13:42:11 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-10-11 13:49:49 +0200 |
commit | 8b26cf4365eb7411138e5aa1eb2d5a38c3f8dea7 (patch) | |
tree | 8c816fe1f88a1ab499b69928aa2d7091c4bb4c89 /src/systemd | |
parent | 650a7022c16d581a9eee71d6856fe147ec9ddd44 (diff) | |
download | NetworkManager-8b26cf4365eb7411138e5aa1eb2d5a38c3f8dea7.tar.gz |
systemd: fix compilation if libc doesn't provide getrandom()
Before commit 650a7022c16d581a9eee71d6856fe147ec9ddd44, we would
always forego using getrandom(). That changed, and now we detect
at compile time whether getrandom() is provided by libc. So, if you
build against recent libc, we use it too.
However, systemd's src/basic/missing_syscall.h also provides getrandom() by
calling the syscall directly. We don't do that, because it seems too cumbersome
to maintain.
Fixes: 650a7022c16d581a9eee71d6856fe147ec9ddd44
Diffstat (limited to 'src/systemd')
-rw-r--r-- | src/systemd/src/basic/random-util.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/systemd/src/basic/random-util.c b/src/systemd/src/basic/random-util.c index 01092a81e6..3b6ddb7dbc 100644 --- a/src/systemd/src/basic/random-util.c +++ b/src/systemd/src/basic/random-util.c @@ -60,7 +60,14 @@ int acquire_random_bytes(void *p, size_t n, bool high_quality_required) { /* Use the getrandom() syscall unless we know we don't have it. */ if (have_syscall != 0) { +#if !HAVE_GETRANDOM + /* XXX: NM: systemd calls the syscall directly in this case. Don't add that workaround. + * If you don't compile against a libc that provides getrandom(), you don't get it. */ + r = -1; + errno = ENOSYS; +#else r = getrandom(p, n, GRND_NONBLOCK); +#endif if (r > 0) { have_syscall = true; if ((size_t) r == n) |