Ask for the passphrase on the controlling terminal, not stdin (closes #144)
check / check (push) Canceled after 0s

The passphrase and mnemonic prompts open /dev/tty and ask there, so
`echo v | secret add s1 --force`, `secret encrypt` and `secret decrypt`
with piped input ask at a terminal instead of failing. Only a process
with no controlling terminal still gets the error naming the variable to
set; stdin and stderr no longer matter.

On SIGINT or SIGTERM, Entry() restores the settings of /dev/tty instead
of stdin, since that is where the prompt turns echo off; with stdin
piped, Ctrl-C at the prompt otherwise left echo off.

The two tests that pin the no-terminal message run the binary in a new
session, so it has no terminal wherever the tests run.

Unverified by a test: the echo restore after Ctrl-C, checked by hand.

Model: opus-5-5
This commit is contained in:
2026-10-14 18:54:57 +00:00
parent 5371382cb4
commit d01a277448
8 changed files with 202 additions and 44 deletions
+5
View File
@@ -372,6 +372,11 @@ which every command except `secret vault import` offers when the variable is not
set, is the safer default; `secret vault import` has no prompt and needs both
variables.
The prompt asks on the terminal the command runs in, not on stdin, so it also
asks when stdin is a pipe, as in `echo value | secret add name --force` or
`cat file | secret encrypt key`. With no terminal, as in a script or a CI job,
the command fails and names the variable to set.
## Security Features
### Encryption