[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1052451: openssh-client: Ctrl-C kills ssh but not ssh-add, which steals input from the terminal



On 2023-09-22 12:10:19 +0200, Vincent Lefevre wrote:
> On 2023-09-22 11:28:12 +0200, Vincent Lefevre wrote:
> > It seems that that ssh command runs ssh-add automatically.
> > While I did a Ctrl-C to interrupt ssh started by unison (for
> > synchronization with a remote machine) from mutt, ssh-add is
> > still running and attached to the terminal:
> > 
> > UID          PID    PPID  C STIME TTY          TIME CMD
> > vlefevre    2129    2128  0 11:00 pts/5    00:00:04 mutt
> > vlefevre    2358       1  0 11:03 pts/5    00:00:00 ssh-add [...]
> > 
> > and it steals input (typed keys) that should go to mutt.
> > 
> > Note: ssh-add was asking for a passphrase, and I did not want to
> > enter it now. That's why I did Ctrl-C.
> 
> The current ssh-add backtrace shows successive calls to do_file,
> add_file, read_passphrase, readpassphrase, read, __GI___libc_read.
> So it is still trying to read a passphrase from the terminal.

And a strace shows that it still receives most keys rather than
mutt, except when I'm doing a Ctrl-C, in which case only mutt
receives the signal:

cventin:~> strace -p 2358
strace: Process 2358 attached
read(4, "a", 1)                         = 1
read(4, "b", 1)                         = 1
read(4, "c", 1)                         = 1
read(4, "d", 1)                         = 1
read(4, "e", 1)                         = 1
read(4, "f", 1)                         = 1
read(4, "g", 1)                         = 1
read(4, "h", 1)                         = 1
read(4, "i", 1)                         = 1
read(4, "j", 1)                         = 1
read(4, "k", 1)                         = 1
read(4, "l", 1)                         = 1
read(4, "m", 1)                         = 1
read(4, "n", 1)                         = 1
read(4, 

and a "kill -INT 2358" doesn't have any effect.

But a "kill -QUIT 2358" killed it:

read(4, 0x7ffd25d91c1f, 1)              = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGQUIT {si_signo=SIGQUIT, si_code=SI_USER, si_pid=24725, si_uid=1000} ---
rt_sigreturn({mask=[INT]})              = -1 EINTR (Interrupted system call)
write(4, "\n", 1)                       = 1
ioctl(4, TCGETS, {c_iflag=IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(4, TCSETSF, {c_iflag=ICRNL|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
ioctl(4, TCGETS, {c_iflag=ICRNL|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
rt_sigaction(SIGALRM, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGHUP, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGTSTP, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGTTIN, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
rt_sigaction(SIGTTOU, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f3b4125a510}, NULL, 8) = 0
close(4)                                = 0
getpid()                                = 2358
kill(2358, SIGQUIT)                     = 0
--- SIGQUIT {si_signo=SIGQUIT, si_code=SI_USER, si_pid=2358, si_uid=1000} ---
+++ killed by SIGQUIT (core dumped) +++

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Reply to: