From 2c6697c443d2c9c908260eed73eb9143223e3ec9 Mon Sep 17 00:00:00 2001 From: "millert@openbsd.org" Date: Tue, 18 Oct 2016 12:41:22 +0000 Subject: [PATCH] upstream commit 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@ Upstream-ID: a31c1f42aa3e2985dcc91e46e6a17bd22e372d69 --- sftp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sftp.c b/sftp.c index 1b5c92498..af6e3a69a 100644 --- a/sftp.c +++ b/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 * @@ -230,6 +230,18 @@ killchild(int signo) _exit(1); } +/* 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) @@ -2213,6 +2225,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); }