From 7ef44e8ad81ce9af2769395a7e24cb8a4c3265d7 Mon Sep 17 00:00:00 2001 From: Derek Straka Date: Mon, 18 Apr 2016 14:34:36 -0400 Subject: [PATCH] rust: add a temp fix to use /dev/urandom Signed-off-by: Derek Straka --- .../files/rust/fix-urandom-during-init.patch | 28 +++++++++++++++++++ recipes-devtools/rust/rust-source.bb | 1 + 2 files changed, 29 insertions(+) create mode 100644 recipes-devtools/rust/files/rust/fix-urandom-during-init.patch diff --git a/recipes-devtools/rust/files/rust/fix-urandom-during-init.patch b/recipes-devtools/rust/files/rust/fix-urandom-during-init.patch new file mode 100644 index 0000000..dceb173 --- /dev/null +++ b/recipes-devtools/rust/files/rust/fix-urandom-during-init.patch @@ -0,0 +1,28 @@ +diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs +index 92c3bf8..b9fd014 100644 +--- a/src/libstd/rand/os.rs ++++ b/src/libstd/rand/os.rs +@@ -46,8 +46,10 @@ + #[cfg(target_arch = "aarch64")] + const NR_GETRANDOM: libc::c_long = 278; + ++ const GRND_NONBLOCK: libc::c_uint = 0x0001; ++ + unsafe { +- libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), 0) ++ libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK) + } + } + +@@ -69,6 +71,10 @@ + let err = errno() as libc::c_int; + if err == libc::EINTR { + continue; ++ } else if err == libc::EAGAIN { ++ let mut reader_rng = ReaderRng::new(File::open("/dev/urandom").unwrap()); ++ reader_rng.fill_bytes(&mut v[read..]); ++ read += v.len() as usize; + } else { + panic!("unexpected getrandom error: {}", err); + } + diff --git a/recipes-devtools/rust/rust-source.bb b/recipes-devtools/rust/rust-source.bb index 1e9b099..1b49eb5 100644 --- a/recipes-devtools/rust/rust-source.bb +++ b/recipes-devtools/rust/rust-source.bb @@ -26,4 +26,5 @@ SRC_URI_append = "\ file://rust/0013-mk-allow-changing-the-platform-configuration-source-.patch \ file://rust-llvm/0000-rust-llvm-remove-extra-slash.patch \ file://rust-installer/0001-add-option-to-disable-rewriting-of-install-paths.patch;patchdir=src/rust-installer \ + file://rust/fix-urandom-during-init.patch \ "