diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-09-11 09:05:51 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2021-09-11 09:05:51 +0000 |
commit | e377c664ea9bb2c23d00207e531c2f9ac3b142d7 (patch) | |
tree | e86c0c104eb82510479c297d2f80ffa275e8eb4f /usr.bin | |
parent | 9befe9a7eaf8c1a474666b71592d918ce1a81407 (diff) |
Do not ignore SIGINT while waiting for input if editline(3) is not used.
Instead, in non-interactive mode, exit sftp(1), like for other serious errors.
As pointed out by dtucker@, when compiled without editline(3) support in
portable OpenSSH, the el == NULL branch is also used for interactive mode.
In that case, discard the input line and provide a fresh prompt to the user
just like in the case where editline(3) is used.
OK djm@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sftp.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index 8b4c090b74c..a920a29fd5c 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.211 2021/08/12 09:59:00 schwarze Exp $ */ +/* $OpenBSD: sftp.c,v 1.212 2021/09/11 09:05:50 schwarze Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -2172,29 +2172,29 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2) interactive = !batchmode && isatty(STDIN_FILENO); err = 0; for (;;) { + struct sigaction sa; const char *line; int count = 0; + interrupted = 0; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = interactive ? read_interrupt : killchild; + if (sigaction(SIGINT, &sa, NULL) == -1) { + debug3("sigaction(%s): %s", strsignal(SIGINT), + strerror(errno)); + break; + } if (el == NULL) { - ssh_signal(SIGINT, SIG_IGN); if (interactive) printf("sftp> "); if (fgets(cmd, sizeof(cmd), infile) == NULL) { if (interactive) printf("\n"); + if (interrupted) + continue; break; } } else { - struct sigaction sa; - - interrupted = 0; - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = read_interrupt; - if (sigaction(SIGINT, &sa, NULL) == -1) { - debug3("sigaction(%s): %s", - strsignal(SIGINT), strerror(errno)); - break; - } if ((line = el_gets(el, &count)) == NULL || count <= 0) { printf("\n"); |