Skip to content

Commit 7407e5e

Browse files
committed
Check for EPERM on getrandom support detection
1 parent ab2bd8c commit 7407e5e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/linux_android.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
4545
}
4646

4747
fn is_getrandom_available() -> bool {
48-
let mut buf: [u8; 0] = [];
49-
match syscall_getrandom(&mut buf, false) {
48+
match syscall_getrandom(&mut [], false) {
49+
Err(err) => match err.raw_os_error() {
50+
Some(libc::ENOSYS) => false, // No kernel support
51+
Some(libc::EPERM) => false, // Blocked by seccomp
52+
_ => true,
53+
}
5054
Ok(_) => true,
51-
Err(err) => err.raw_os_error() != Some(libc::ENOSYS),
5255
}
5356
}
5457

0 commit comments

Comments
 (0)