summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2016-10-18 12:41:22 +0000
committermillert <millert@openbsd.org>2016-10-18 12:41:22 +0000
commit88a7773be13d94e97c9fef45cdc85dd01e1448c0 (patch)
tree73852456c189ae5d8d79379f0344c8ef6325b1c2
parentUse "continue;" instead of a bare ";" in the for() loop example (diff)
downloadwireguard-openbsd-88a7773be13d94e97c9fef45cdc85dd01e1448c0.tar.xz
wireguard-openbsd-88a7773be13d94e97c9fef45cdc85dd01e1448c0.zip
Install a signal handler for tty-generated signals and wait for the
ssh child to suspend before suspending sftp. This lets ssh restore the terminal mode as needed when it is suspended at the password prompt. OK dtucker@
-rw-r--r--usr.bin/ssh/sftp.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c
index c34e8367e4d..063cd2d8c98 100644
--- a/usr.bin/ssh/sftp.c
+++ b/usr.bin/ssh/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.176 2016/09/12 01:22:38 deraadt Exp $ */
+/* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -210,6 +210,18 @@ killchild(int signo)
/* ARGSUSED */
static void
+suspchild(int signo)
+{
+ if (sshpid > 1) {
+ kill(sshpid, signo);
+ while (waitpid(sshpid, NULL, WUNTRACED) == -1 && errno == EINTR)
+ continue;
+ }
+ kill(getpid(), SIGSTOP);
+}
+
+/* ARGSUSED */
+static void
cmd_interrupt(int signo)
{
const char msg[] = "\rInterrupt \n";
@@ -2171,6 +2183,9 @@ connect_to_server(char *path, char **args, int *in, int *out)
signal(SIGTERM, killchild);
signal(SIGINT, killchild);
signal(SIGHUP, killchild);
+ signal(SIGTSTP, suspchild);
+ signal(SIGTTIN, suspchild);
+ signal(SIGTTOU, suspchild);
close(c_in);
close(c_out);
}