Skip to content

Commit

Permalink
Check for EPERM on getrandom support detection
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlr committed Jun 23, 2019
1 parent ab2bd8c commit 7407e5e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/linux_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
}

fn is_getrandom_available() -> bool {
let mut buf: [u8; 0] = [];
match syscall_getrandom(&mut buf, false) {
match syscall_getrandom(&mut [], false) {
Err(err) => match err.raw_os_error() {
Some(libc::ENOSYS) => false, // No kernel support
Some(libc::EPERM) => false, // Blocked by seccomp
_ => true,
}
Ok(_) => true,
Err(err) => err.raw_os_error() != Some(libc::ENOSYS),
}
}

Expand Down

0 comments on commit 7407e5e

Please sign in to comment.