We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
/dev/urandom
EPERM
getrandom
1 parent 6cc24f2 commit bd8885dCopy full SHA for bd8885d
src/libstd/sys/unix/rand.rs
@@ -47,7 +47,12 @@ mod imp {
47
let err = errno() as libc::c_int;
48
if err == libc::EINTR {
49
continue;
50
- } else if err == libc::ENOSYS {
+ } else if err == libc::ENOSYS || err == libc::EPERM {
51
+ // Fall back to reading /dev/urandom if `getrandom` is not
52
+ // supported on the current kernel.
53
+ //
54
+ // Also fall back in case it is disabled by something like
55
+ // seccomp or inside of virtual machines.
56
GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed);
57
return false;
58
} else if err == libc::EAGAIN {
0 commit comments