From: Thomas Devoogdt <thomas.devoo...@barco.com>

getrandom() was introduced in version 3.17 of the Linux kernel.
       Support was added to glibc in version 2.25.

https://man7.org/linux/man-pages/man2/getrandom.2.html

read_new_seed will anyway fallback to /dev/{u}random if (ret != len)

Signed-off-by: Thomas Devoogdt <thomas.devoo...@barco.com>
---
 miscutils/seedrng.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
index 967741dc7..663fb47a4 100644
--- a/miscutils/seedrng.c
+++ b/miscutils/seedrng.c
@@ -42,9 +42,14 @@
 #include "libbb.h"
 
 #include <linux/random.h>
-#include <sys/random.h>
 #include <sys/file.h>
 
+#if __GLIBC_PREREQ(2, 25)
+#include <sys/random.h>
+#else
+#define getrandom(buf, len, flags) (-1)
+#endif
+
 #ifndef GRND_INSECURE
 #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this 
yet. */
 #endif
-- 
2.39.0

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to