Detect password prompts and answer via read-passwd#241
Merged
Conversation
Mirrors libghostty's canonical+!echo heuristic (see ghostty/src/termio/Exec.zig) so password input from sudo/ssh/gpg goes through read-passwd instead of Emacs's key handling, where it would land in view-lossage and the recent-keys ring. The Zig binding ghostel--pty-password-input-p opens the slave path and runs tcgetattr. Falls back to a regex on the cursor row when echo state can't be observed (remote ssh, programs that don't toggle echo). Post-submission re-fires are suppressed while the cursor stays on the row, to bridge the brief window where sudo holds the tty in canonical+!echo before restoring; cursor moving off the row (wrong-password retry, next program) re-arms naturally. ghostel-password-prompt-functions is a chain of (ROW) -> string-or-nil sources, tried via run-hook-with-args-until-success. Default reads with read-passwd; users prepend their own (auth-source, 1Password, pass, ...) and the default acts as the fallback.
c7eb0f1 to
c0d7f8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sudo,ssh,gpg,passwd, …) and answers them viaread-passwdinstead of streaming through Emacs's key pipeline (where they'd land inview-lossageand the recent-keys ring).ghostel--pty-password-input-pmirrors libghostty'scanonical && !echoheuristic fromghostty/src/termio/Exec.zig. Regex fallback on the cursor row covers remote ssh / programs that don't toggle echo.ghostel-password-prompt-functionsis a chain of(ROW) -> string-or-nilsources, tried viarun-hook-with-args-until-success. Default reads withread-passwd; users prepend their own (auth-source, 1Password, pass, …) and the default acts as the fallback. Docstring includes a TRAMP-awareauth-source-pick-first-passwordexample.(concat pwd "\r")wire copy isclear-string'd after sending so the password doesn't sit in the heap until the next GC. The source's return value is deliberately not cleared (could be a shared auth-source cache entry).ghostty_feature_requests/06-password-input-setter.mddrafts an upstream proposal to add a setter for libghostty'spassword_inputflag — currently the public C-API has only a getter, so libghostty-vt embedders can't round-trip through it.Test plan
make -j4 allclean: build + lint + 60 elisp + 137 native + 316 evil tests, no unexpected failuressudo -K; sudo truein a ghostel buffer —read-passwdminibuffer pops up, password accepted on first try, mode-line shows🔒Passwordwhile open,view-lossagedoes not contain the passwordghostel-test-detect-suppresses-while-on-handled-row)ghostel-test-prompt-password-clears-wire-copy)ghostel-test-prompt-password-tries-sources-in-order)~/.authinfo.gpgentry — recommended before merging)