← Commit list

200a9669f

Denys Vlasenko
Denys Vlasenko
2023-04-10
SUCCESS Duration: 159s

Subject

seedrng: fix for glibc <= 2.24 not providing getrandom()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/seedrng.c+14 -0
@@ -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