mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 09:53:26 +00:00
Rollup merge of #60453 - tbu-:pr_getrandom_enoperm, r=sfackler
Fall back to `/dev/urandom` on `EPERM` for `getrandom` This can happen because of seccomp or some VMs. Fixes #52609.
This commit is contained in:
commit
5a08ca38de
@ -47,7 +47,12 @@ mod imp {
|
||||
let err = errno() as libc::c_int;
|
||||
if err == libc::EINTR {
|
||||
continue;
|
||||
} else if err == libc::ENOSYS {
|
||||
} else if err == libc::ENOSYS || err == libc::EPERM {
|
||||
// Fall back to reading /dev/urandom if `getrandom` is not
|
||||
// supported on the current kernel.
|
||||
//
|
||||
// Also fall back in case it is disabled by something like
|
||||
// seccomp or inside of virtual machines.
|
||||
GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed);
|
||||
return false;
|
||||
} else if err == libc::EAGAIN {
|
||||
|
Loading…
Reference in New Issue
Block a user