From b69aaa8db7b6d079a2efad6d57796daedd449886 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 4 Jun 2003 22:51:24 +1000 Subject: [PATCH] - djm@cvs.openbsd.org 2003/06/04 12:40:39 [scp.c] kill ssh process upon receipt of signal, bz #241. based on patch from esb AT hawaii.edu; ok markus@ --- ChangeLog | 6 +++++- scp.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c4ba4754..db161a460 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,10 @@ - djm@cvs.openbsd.org 2003/06/04 12:18:49 [scp.c] ansify; ok markus@ + - djm@cvs.openbsd.org 2003/06/04 12:40:39 + [scp.c] + kill ssh process upon receipt of signal, bz #241. + based on patch from esb AT hawaii.edu; ok markus@ - (djm) Update to fix of bug #584: lock card before return. From larsch@trustcenter.de @@ -450,4 +454,4 @@ - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. Report from murple@murple.net, diagnosis from dtucker@zip.com.au -$Id: ChangeLog,v 1.2778 2003/06/04 12:51:08 djm Exp $ +$Id: ChangeLog,v 1.2779 2003/06/04 12:51:24 djm Exp $ diff --git a/scp.c b/scp.c index 6d2692e16..16734875b 100644 --- a/scp.c +++ b/scp.c @@ -71,7 +71,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.104 2003/06/04 12:18:49 djm Exp $"); +RCSID("$OpenBSD: scp.c,v 1.105 2003/06/04 12:40:39 djm Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -107,7 +107,16 @@ int showprogress = 1; char *ssh_program = _PATH_SSH_PROGRAM; /* This is used to store the pid of ssh_program */ -pid_t do_cmd_pid; +pid_t do_cmd_pid = -1; + +static void +killchild(int signo) +{ + if (do_cmd_pid > 1) + kill(do_cmd_pid, signo); + + _exit(1); +} /* * This function executes the given command as the specified user on the @@ -170,6 +179,9 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) *fdout = pin[1]; close(pout[1]); *fdin = pout[0]; + signal(SIGTERM, killchild); + signal(SIGINT, killchild); + signal(SIGHUP, killchild); return 0; }