From 34f73ba19fe83c1c7d758a9b00fb5860e469941c Mon Sep 17 00:00:00 2001 From: Minseong Choi Date: Tue, 22 Sep 2026 13:52:51 +0900 Subject: [PATCH] fix(bootstrap): detect a missing terminal by opening /dev/tty prompt_install_mode guarded its prompt with `[ ! -r /dev/tty ]`, which never fires on Linux: /dev/tty is mode 0666 whether or not the process has a controlling terminal, and only opening it fails. Without a terminal the menu was printed, the read failed with "No such device or address", and the default was taken by accident rather than by the documented path. The guard now opens /dev/tty in a subshell and takes the "no terminal for a prompt" path when that fails. --- deploy/bootstrap.sh | 5 +++-- deploy/bootstrap_test.sh | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/deploy/bootstrap.sh b/deploy/bootstrap.sh index b2dbf99..eff72f3 100644 --- a/deploy/bootstrap.sh +++ b/deploy/bootstrap.sh @@ -2240,8 +2240,9 @@ prompt_install_mode() { # No override: ask on the controlling terminal. Under `curl | sudo bash` stdin # is the script, so we must read /dev/tty, not stdin. No tty (CI/cloud-init) → - # take the default. - if [ ! -r /dev/tty ]; then + # take the default. Open it to find out: /dev/tty is mode 0666 on every Linux host, so + # `-r` passes even when there is no controlling terminal and only the open fails. + if ! (: /dev/null; then INSTALL_MODE="$def" log "no terminal for a prompt; defaulting to a ${def} install (set FELIS_INSTALL_MODE=full or nano to override)" return 0 diff --git a/deploy/bootstrap_test.sh b/deploy/bootstrap_test.sh index 0b462f3..d5af411 100644 --- a/deploy/bootstrap_test.sh +++ b/deploy/bootstrap_test.sh @@ -363,8 +363,9 @@ else "$(run_mode "$sdir/felis-nano.service" "$sdir/absent.done")" expect "a host with the full install re-runs as full" "MODE: full" \ "$(run_mode "$sdir/felis-nano.service" "$sdir/bootstrap.done")" - expect "a fresh host defaults to full" "MODE: full" \ - "$(run_mode "$sdir/absent.service" "$sdir/absent.done")" + out="$(run_mode "$sdir/absent.service" "$sdir/absent.done")" + expect "a fresh host defaults to full" "MODE: full" "$out" + expect "no controlling terminal takes the no-prompt path" "LOG: no terminal for a prompt" "$out" # felis setup goes on to need the control plane, so under it nano is refused, and the # nano-only default above must not apply either. expect "felis setup refuses FELIS_INSTALL_MODE=nano" "DIE: felis setup installs the full control plane" \