Do not prefer a dialog on a machine with nowhere to draw it
config/bash/shell exported SSH_ASKPASS=ksshaskpass with SSH_ASKPASS_REQUIRE=prefer on every machine. `prefer` means ssh and git reach for that dialog BEFORE the terminal prompt, so on a headless server the prompt that would have worked was skipped in favour of a KDE window that cannot open: error: /usr/bin/ksshaskpass died of signal 6 fatal: could not read Username for 'https://git.gbrown.org' A push from a server failed to ASK for a username rather than failing to authenticate. The shell environment is the one half of Panama a server does install, so nothing downstream was going to catch this. The export is now conditional on a session existing to draw in, and on the binary being there to run. The headless branch also CLEARS both variables rather than merely declining to set them: an askpass inherited from a parent that had a display, or from a login predating this guard, is exactly as unusable and a guard that only withholds leaves it in place. A fresh login shell on the repaired server still reported prefer until it cleared them. A desktop is unchanged; a server, a serial console and a plain SSH session fall back to the terminal prompt, which works. tests/setup/headless-askpass-contract pins every branch, the inherited case included, and fails against the previous code and against a guard that only withholds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
a493fa5584
commit
a664cf68f5
4 files changed
+102
-3
No files matched your search
+17
-2
@@ -16,8 +16,23 @@ unset PANAMA_ENV
|
||||
# Editor used by CLI
|
||||
export EDITOR="nvim"
|
||||
export SUDO_EDITOR="$EDITOR"
|
||||
export SSH_ASKPASS=/usr/bin/ksshaskpass
|
||||
export SSH_ASKPASS_REQUIRE=prefer
|
||||
# A graphical askpass, and only where there is a session to draw it in.
|
||||
# SSH_ASKPASS_REQUIRE=prefer means ssh and git reach for the dialog BEFORE the
|
||||
# terminal prompt, so on a headless machine the prompt that would have worked
|
||||
# is skipped in favour of one that cannot open: `git push` then fails reading
|
||||
# a username rather than asking for it. The desktop keeps the dialog; a
|
||||
# server, a serial console and a plain SSH session fall back to the terminal.
|
||||
if [ -n "${WAYLAND_DISPLAY:-}${DISPLAY:-}" ] && [ -x /usr/bin/ksshaskpass ]; then
|
||||
export SSH_ASKPASS=/usr/bin/ksshaskpass
|
||||
export SSH_ASKPASS_REQUIRE=prefer
|
||||
else
|
||||
# Cleared, not merely left unset. An askpass inherited from a parent that
|
||||
# did have a display -- an agent's shell, a forwarded environment, a login
|
||||
# that predates this guard -- is exactly as unusable here as one this file
|
||||
# set itself, and declining to add it does nothing about a value already in
|
||||
# the environment.
|
||||
unset SSH_ASKPASS SSH_ASKPASS_REQUIRE
|
||||
fi
|
||||
|
||||
# Define Paths
|
||||
export CARGO_PATH="$HOME/.cargo"
|
||||
|
||||
Reference in new issue
Block a user