diff options
author | Ron Yorston <rmy@pobox.com> | 2023-04-17 07:32:52 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-04-17 07:32:52 +0100 |
commit | 8cdeb571cfbf3bb6edc44779e46537b072b8cd08 (patch) | |
tree | 9f3ad1d205418197bc53348b61f702602229a90d /miscutils | |
parent | 41827dd448c001b52b4f0e591ea605cb5de1d230 (diff) | |
parent | d2b81b3dc2b31d32e1060d3ea8bd998d30a37d8a (diff) | |
download | busybox-w32-8cdeb571cfbf3bb6edc44779e46537b072b8cd08.tar.gz busybox-w32-8cdeb571cfbf3bb6edc44779e46537b072b8cd08.tar.bz2 busybox-w32-8cdeb571cfbf3bb6edc44779e46537b072b8cd08.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/seedrng.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c index 967741dc7..3bf6e2ea7 100644 --- a/miscutils/seedrng.c +++ b/miscutils/seedrng.c | |||
@@ -42,11 +42,31 @@ | |||
42 | #include "libbb.h" | 42 | #include "libbb.h" |
43 | 43 | ||
44 | #include <linux/random.h> | 44 | #include <linux/random.h> |
45 | #include <sys/random.h> | ||
46 | #include <sys/file.h> | 45 | #include <sys/file.h> |
47 | 46 | ||
47 | /* Fix up glibc <= 2.24 not having getrandom() */ | ||
48 | #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24 | ||
49 | #include <sys/syscall.h> | ||
50 | static ssize_t getrandom(void *buffer, size_t length, unsigned flags) | ||
51 | { | ||
52 | # if defined(__NR_getrandom) | ||
53 | return syscall(__NR_getrandom, buffer, length, flags); | ||
54 | # else | ||
55 | errno = ENOSYS; | ||
56 | return -1; | ||
57 | # endif | ||
58 | } | ||
59 | #else | ||
60 | #include <sys/random.h> | ||
61 | #endif | ||
62 | |||
63 | /* Apparently some headers don't ship with this yet. */ | ||
64 | #ifndef GRND_NONBLOCK | ||
65 | #define GRND_NONBLOCK 0x0001 | ||
66 | #endif | ||
67 | |||
48 | #ifndef GRND_INSECURE | 68 | #ifndef GRND_INSECURE |
49 | #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */ | 69 | #define GRND_INSECURE 0x0004 |
50 | #endif | 70 | #endif |
51 | 71 | ||
52 | #define DEFAULT_SEED_DIR "/var/lib/seedrng" | 72 | #define DEFAULT_SEED_DIR "/var/lib/seedrng" |