Skip to content

Commit c5a119d

Browse files
committed
bootupd: add --pty when stdin is a terminal
From Colin's pointer: `systemd-run` breaks when forwarding a physical (`/dev/tty*` with label `tty_device_t`) as opposed to virtual console (`/dev/pts` with label `user_devpts_t`). When stdin is a terminal, we should definitely use `-t`. Fixes #902
1 parent 9a4eeaf commit c5a119d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cli/bootupctl.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,15 @@ fn ensure_running_in_systemd() -> Result<()> {
179179
.stderr(Stdio::null())
180180
.spawn()?
181181
.wait()?;
182+
let mut systemd_args = SYSTEMD_ARGS_BOOTUPD.to_vec();
183+
// we need --pty when detect that stdin is a terminal
184+
// see discussion in https://github.com/coreos/bootupd/issues/902#issuecomment-2794680163
185+
let tty_path = std::fs::read_link("/proc/self/fd/0")?;
186+
if tty_path.starts_with("/dev/tty") {
187+
systemd_args.push("--pty");
188+
}
182189
let r = Command::new("systemd-run")
183-
.args(SYSTEMD_ARGS_BOOTUPD)
190+
.args(&systemd_args)
184191
.args(
185192
SYSTEMD_PROPERTIES
186193
.into_iter()

0 commit comments

Comments
 (0)