1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #813 from shalupov/fix-windows-tests-startup

Fix tests startup under Windows
This commit is contained in:
Michael Gehring 2016-02-14 17:24:08 +01:00
commit 01ca5cac7b

View file

@ -282,7 +282,19 @@ impl UCommand {
let mut cmd = Command::new(arg.as_ref());
cmd.current_dir(curdir.as_ref());
if env_clear {
cmd.env_clear();
if cfg!(windows) {
// %SYSTEMROOT% is required on Windows to initialize crypto provider
// ... and crypto provider is required for std::rand
// From procmon: RegQueryValue HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider\Microsoft Strong Cryptographic Provider\Image Path
// SUCCESS Type: REG_SZ, Length: 66, Data: %SystemRoot%\system32\rsaenh.dll"
for (key, _) in env::vars_os() {
if key.as_os_str() != "SYSTEMROOT" {
cmd.env_remove(key);
}
}
} else {
cmd.env_clear();
}
}
cmd
},