summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-07-02 13:37:33 +1000
committerDamien Miller <djm@mindrot.org>2010-07-02 13:37:33 +1000
commit0979b40934a59615d8fa1535103d51f11c04bad2 (patch)
treec7422f717e95bf6355d428f08a9c057689040947
parentd59dab83536d4a539e795ff5ce2be6b952d57e24 (diff)
- millert@cvs.openbsd.org 2010/07/01 13:06:59
[scp.c] Fix a longstanding problem where if you suspend scp at the password/passphrase prompt the terminal mode is not restored. OK djm@
-rw-r--r--ChangeLog5
-rw-r--r--scp.c20
2 files changed, 24 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b214e86..cf93dc9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,11 @@
- jmc@cvs.openbsd.org 2010/06/30 07:28:34
[sshd_config.5]
tweak previous;
+ - millert@cvs.openbsd.org 2010/07/01 13:06:59
+ [scp.c]
+ Fix a longstanding problem where if you suspend scp at the
+ password/passphrase prompt the terminal mode is not restored.
+ OK djm@
20100627
- (tim) [openbsd-compat/port-uw.c] Reorder includes. auth-options.h now needs
diff --git a/scp.c b/scp.c
index 09efb82a..e07de42f 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.165 2009/12/20 07:28:36 guenther Exp $ */
+/* $OpenBSD: scp.c,v 1.166 2010/07/01 13:06:59 millert Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -156,6 +156,20 @@ killchild(int signo)
exit(1);
}
+static void
+suspchild(int signo)
+{
+ int status;
+
+ if (do_cmd_pid > 1) {
+ kill(do_cmd_pid, signo);
+ while (waitpid(do_cmd_pid, &status, WUNTRACED) == -1 &&
+ errno == EINTR)
+ ;
+ kill(getpid(), SIGSTOP);
+ }
+}
+
static int
do_local_cmd(arglist *a)
{
@@ -232,6 +246,10 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
close(reserved[0]);
close(reserved[1]);
+ signal(SIGTSTP, suspchild);
+ signal(SIGTTIN, suspchild);
+ signal(SIGTTOU, suspchild);
+
/* Fork a child to execute the command on the remote host using ssh. */
do_cmd_pid = fork();
if (do_cmd_pid == 0) {