Skip to content

Commit 4cfe664

Browse files
committed
Don't include a new line character in a password
1 parent 068132a commit 4cfe664

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

codechain/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ fn new_miner(config: &config::Config, spec: &Spec, ap: Arc<AccountProvider>) ->
209209
Ok(..) => match config.mining.password_path {
210210
None => return Err("mining.password_path is not specified".to_string()),
211211
Some(ref password_path) => match fs::read_to_string(password_path) {
212-
Ok(password) => {
213-
miner.set_engine_signer(engine_signer, password).map_err(|e| format!("{:?}", e))?
212+
Ok(content) => {
213+
// Read the first line as password.
214+
let password = content.lines().next().ok_or("Password file is empty")?;
215+
miner
216+
.set_engine_signer(engine_signer, password.to_string())
217+
.map_err(|e| format!("{:?}", e))?
214218
}
215219
Err(_) => return Err(format!("Failed to read the password file")),
216220
},

0 commit comments

Comments
 (0)