Bump secrecy from 0.6.0 to 0.7.0 (#7568)

* Bump secrecy from 0.6.0 to 0.7.0

Bumps [secrecy](https://github.com/iqlusioninc/crates) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/iqlusioninc/crates/releases)
- [Commits](https://github.com/iqlusioninc/crates/compare/secrecy/v0.6.0...secrecy/v0.7.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix compilation errors

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
dependabot[bot]
2020-11-22 12:57:21 +01:00
committed by GitHub
parent 5693a1b88a
commit 8716c70a97
3 changed files with 10 additions and 19 deletions
@@ -22,8 +22,7 @@ use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
use crate::error;
use sp_core::crypto::{SecretString, Zeroize};
use std::str::FromStr;
use sp_core::crypto::SecretString;
/// default sub directory for the key store
const DEFAULT_KEYSTORE_CONFIG_PATH: &'static str = "keystore";
@@ -72,21 +71,15 @@ impl KeystoreParams {
let password = if self.password_interactive {
#[cfg(not(target_os = "unknown"))]
{
let mut password = input_keystore_password()?;
let secret = std::str::FromStr::from_str(password.as_str())
.map_err(|()| "Error reading password")?;
password.zeroize();
Some(secret)
let password = input_keystore_password()?;
Some(SecretString::new(password))
}
#[cfg(target_os = "unknown")]
None
} else if let Some(ref file) = self.password_filename {
let mut password = fs::read_to_string(file)
let password = fs::read_to_string(file)
.map_err(|e| format!("{}", e))?;
let secret = std::str::FromStr::from_str(password.as_str())
.map_err(|()| "Error reading password")?;
password.zeroize();
Some(secret)
Some(SecretString::new(password))
} else {
self.password.clone()
};
@@ -104,10 +97,8 @@ impl KeystoreParams {
let (password_interactive, password) = (self.password_interactive, self.password.clone());
let pass = if password_interactive {
let mut password = rpassword::read_password_from_tty(Some("Key password: "))?;
let pass = Some(FromStr::from_str(&password).map_err(|()| "Error reading password")?);
password.zeroize();
pass
let password = rpassword::read_password_from_tty(Some("Key password: "))?;
Some(SecretString::new(password))
} else {
password
};