From 2200604d9c101888df658f9483290a13952c6b1c Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Mon, 14 Jan 2019 14:19:04 -0800 Subject: remove rand crate the few uses of rand::thread_rng() have been replaced with either prngs or reads from /dev/urandom. the implementations are under the `rand_ish` minicrate. `protoc-rust` depends on `tempdir`, which relies on rand, so `tempdir` has been patched with a rewritten version that does not have rand as a dependency. BUG=chromium:921795 TEST=cargo test --features plugin Change-Id: I6f1c7d7a1aeef4dd55ac71e58294d16c291b8871 Reviewed-on: https://chromium-review.googlesource.com/1409705 Commit-Ready: Daniel Prilik Tested-by: kokoro Reviewed-by: Zach Reizner --- tests/plugins.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/plugins.rs b/tests/plugins.rs index 20adcab..6176a32 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -4,11 +4,9 @@ #![cfg(feature = "plugin")] -extern crate rand; +extern crate rand_ish; extern crate sys_util; -use rand::{thread_rng, Rng}; - use std::env::{current_exe, var_os}; use std::ffi::OsString; use std::fs::{remove_file, File}; @@ -19,6 +17,7 @@ use std::process::{Command, Stdio}; use std::thread::sleep; use std::time::Duration; +use rand_ish::urandom_str; use sys_util::{ioctl, SharedMemory}; struct RemovePath(PathBuf); @@ -56,7 +55,8 @@ fn get_crosvm_path() -> PathBuf { fn build_plugin(src: &str) -> RemovePath { let libcrosvm_plugin_dir = get_target_path(); let mut out_bin = libcrosvm_plugin_dir.clone(); - out_bin.push(thread_rng().gen_ascii_chars().take(10).collect::()); + let randbin = urandom_str(10).expect("failed to generate random bin name"); + out_bin.push(randbin); let mut child = Command::new(var_os("CC").unwrap_or(OsString::from("cc"))) .args(&["-Icrosvm_plugin", "-pthread", "-o"]) // crosvm.h location and set output path. .arg(&out_bin) -- cgit 1.4.1