password helper: inherit stdin, stderr

should make fido2luks much easier to use in boot scripts since it will
allow for usage as follows:

`fido2luks open-token /dev/disk/by-uuid/sda1 test 'bash -c "read -p Pass PW 1>&2; echo $PW"'`

which will read the password from the current terminal
This commit is contained in:
shimun 2021-07-16 15:11:31 +02:00
parent 5496c4e61b
commit f53096dc5b
Signed by: shimun
GPG Key ID: E81D8382DC2F971B

View File

@ -7,6 +7,7 @@ use std::fs::File;
use std::io::Read; use std::io::Read;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use std::process::Stdio;
use std::str::FromStr; use std::str::FromStr;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@ -156,6 +157,8 @@ impl PasswordHelper {
let password = Command::new("sh") let password = Command::new("sh")
.arg("-c") .arg("-c")
.arg(&password_helper) .arg(&password_helper)
.stdin(Stdio::inherit())
.stderr(Stdio::inherit())
.output() .output()
.map_err(|e| Fido2LuksError::AskPassError { .map_err(|e| Fido2LuksError::AskPassError {
cause: error::AskPassError::IO(e), cause: error::AskPassError::IO(e),