mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 04:22:15 +02:00
util/nvmutil: better urandom portability
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -305,6 +305,10 @@ typedef char static_assert_off_t_is_32[(sizeof(off_t) >= 4) ? 1 : -1];
|
|||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_NONBLOCK
|
||||||
|
#define O_NONBLOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef O_CLOEXEC
|
#ifndef O_CLOEXEC
|
||||||
#define O_CLOEXEC 0
|
#define O_CLOEXEC 0
|
||||||
#endif
|
#endif
|
||||||
@@ -1382,9 +1386,11 @@ read_urandom(void)
|
|||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|
||||||
fd = open("/dev/urandom", O_RDONLY);
|
fd = open("/dev/urandom", O_RDONLY | O_NONBLOCK);
|
||||||
if (fd < 0)
|
if (fd < 0) /* older openbsd */
|
||||||
fd = open("/dev/random", O_RDONLY);
|
fd = open("/dev/arandom", O_RDONLY | O_NONBLOCK);
|
||||||
|
if (fd < 0) /* super old unix (could block) */
|
||||||
|
fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 16;
|
return 16;
|
||||||
|
|||||||
Reference in New Issue
Block a user