cd02f96b87
The current Busybox version (1.36.0) fails to build with some
libc/linux combinations where getrandom() is not available. Two fixes
for glibc already exists upstream, so backport them here. A third
one (submitted upstream, not part of the main branch yet) was needed
to be able to compile with older musl and uClibc versions (or older
kernels).
This fixes the following build failure raised since commit
d68b617993
:
miscutils/seedrng.c:45:24: fatal error: sys/random.h: No such file or directory
#include <sys/random.h>
Fixes:
- http://autobuild.buildroot.net/results/44a0476b86c579e6aa658f156f0292958d40513c
- http://autobuild.buildroot.net/results/ed028160db397581558fd8c96755621dd8298bb1
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624008
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624034
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624044
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624048
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624051
It also fixes the following (similar) build failure, raised since the
same commit:
miscutils/lib.a(seedrng.o): In function `seedrng_main':
seedrng.c:(.text.seedrng_main+0x26c): undefined reference to `getrandom'
seedrng.c:(.text.seedrng_main+0x2e8): undefined reference to `getrandom'
collect2: error: ld returned 1 exit status
Fixes:
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624028
- https://gitlab.com/buildroot.org/buildroot/-/jobs/4122624031
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
40 lines
1.2 KiB
Diff
40 lines
1.2 KiB
Diff
From 200a9669fbf6f06894e4243cccc9fc11a1a6073a Mon Sep 17 00:00:00 2001
|
|
From: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Date: Mon, 10 Apr 2023 17:26:04 +0200
|
|
Subject: [PATCH] seedrng: fix for glibc <= 2.24 not providing getrandom()
|
|
|
|
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
|
Upstream: https://git.busybox.net/busybox/commit/?id=200a9669fbf6f06894e4243cccc9fc11a1a6073a
|
|
---
|
|
miscutils/seedrng.c | 14 ++++++++++++++
|
|
1 file changed, 14 insertions(+)
|
|
|
|
diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
|
|
index 967741dc7..7cc855141 100644
|
|
--- a/miscutils/seedrng.c
|
|
+++ b/miscutils/seedrng.c
|
|
@@ -45,6 +45,20 @@
|
|
#include <sys/random.h>
|
|
#include <sys/file.h>
|
|
|
|
+/* Fix up glibc <= 2.24 not having getrandom() */
|
|
+#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24
|
|
+#include <sys/syscall.h>
|
|
+# define getrandom(...) bb_getrandom(__VA_ARGS__)
|
|
+static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
|
|
+{
|
|
+# if defined(__NR_getrandom)
|
|
+ return syscall(__NR_getrandom, buffer, length, flags);
|
|
+# else
|
|
+ return ENOSYS;
|
|
+# endif
|
|
+}
|
|
+#endif
|
|
+
|
|
#ifndef GRND_INSECURE
|
|
#define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */
|
|
#endif
|
|
--
|
|
2.39.1
|
|
|