Skip to content

Commit 68df5ec

Browse files
committed
faux-mgs: support PERMSLIP environment variable for online unlock
1 parent c691112 commit 68df5ec

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

faux-mgs/src/main.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,20 +1967,26 @@ fn unlock_permslip(
19671967
key_name: String,
19681968
challenge: UnlockChallenge,
19691969
) -> Result<UnlockResponse> {
1970+
use std::env;
19701971
use std::process::{Command, Stdio};
19711972

1972-
let mut permslip = Command::new("permslip")
1973-
.arg("sign")
1974-
.arg(key_name)
1975-
.arg("--sshauth")
1976-
.arg("--kind=tech-port-unlock-challenge")
1977-
.stdin(Stdio::piped())
1978-
.stdout(Stdio::piped())
1979-
.stderr(Stdio::inherit())
1980-
.spawn()
1981-
.context(
1982-
"unable to execute `permslip`, is it in your PATH and executable?",
1983-
)?;
1973+
let mut permslip = Command::new(
1974+
env::var("PERMSLIP").unwrap_or_else(|_| String::from("permslip")),
1975+
)
1976+
.arg("sign")
1977+
.arg(key_name)
1978+
.arg("--sshauth")
1979+
.arg("--kind=tech-port-unlock-challenge")
1980+
.stdin(Stdio::piped())
1981+
.stdout(Stdio::piped())
1982+
.stderr(Stdio::inherit())
1983+
.spawn()
1984+
.map_err(|_| {
1985+
anyhow!(
1986+
"Unable to execute `permslip`, is it in your PATH and executable? \
1987+
You may also override it with the PERMSLIP environment variable."
1988+
)
1989+
})?;
19841990

19851991
let mut input =
19861992
permslip.stdin.take().context("can't get permslip input")?;

0 commit comments

Comments
 (0)