summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2020-02-21 11:57:14 +0000
committerColin Watson <cjwatson@debian.org>2020-02-21 11:57:14 +0000
commitf0de78bd4f29fa688c5df116f3f9cd43543a76d0 (patch)
tree856b0dee3f2764c13a32dad5ffe2424fab7fef41 /sftp.c
parent4213eec74e74de6310c27a40c3e9759a08a73996 (diff)
parent8aa3455b16fddea4c0144a7c4a1edb10ec67dcc8 (diff)
Import openssh_8.2p1.orig.tar.gz
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/sftp.c b/sftp.c
index b66037f16..ff14d3c29 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.195 2019/10/02 00:42:30 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.197 2020/01/23 07:10:22 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -220,9 +220,12 @@ static const struct CMD cmds[] = {
220static void 220static void
221killchild(int signo) 221killchild(int signo)
222{ 222{
223 if (sshpid > 1) { 223 pid_t pid;
224 kill(sshpid, SIGTERM); 224
225 waitpid(sshpid, NULL, 0); 225 pid = sshpid;
226 if (pid > 1) {
227 kill(pid, SIGTERM);
228 waitpid(pid, NULL, 0);
226 } 229 }
227 230
228 _exit(1); 231 _exit(1);
@@ -2240,7 +2243,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
2240 interactive = !batchmode && isatty(STDIN_FILENO); 2243 interactive = !batchmode && isatty(STDIN_FILENO);
2241 err = 0; 2244 err = 0;
2242 for (;;) { 2245 for (;;) {
2243 signal(SIGINT, SIG_IGN); 2246 ssh_signal(SIGINT, SIG_IGN);
2244 2247
2245 if (el == NULL) { 2248 if (el == NULL) {
2246 if (interactive) 2249 if (interactive)
@@ -2272,14 +2275,14 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
2272 2275
2273 /* Handle user interrupts gracefully during commands */ 2276 /* Handle user interrupts gracefully during commands */
2274 interrupted = 0; 2277 interrupted = 0;
2275 signal(SIGINT, cmd_interrupt); 2278 ssh_signal(SIGINT, cmd_interrupt);
2276 2279
2277 err = parse_dispatch_command(conn, cmd, &remote_path, 2280 err = parse_dispatch_command(conn, cmd, &remote_path,
2278 startdir, batchmode, !interactive && el == NULL); 2281 startdir, batchmode, !interactive && el == NULL);
2279 if (err != 0) 2282 if (err != 0)
2280 break; 2283 break;
2281 } 2284 }
2282 signal(SIGCHLD, SIG_DFL); 2285 ssh_signal(SIGCHLD, SIG_DFL);
2283 free(remote_path); 2286 free(remote_path);
2284 free(startdir); 2287 free(startdir);
2285 free(conn); 2288 free(conn);
@@ -2336,20 +2339,20 @@ connect_to_server(char *path, char **args, int *in, int *out)
2336 * kill it too. Contrawise, since sftp sends SIGTERMs to the 2339 * kill it too. Contrawise, since sftp sends SIGTERMs to the
2337 * underlying ssh, it must *not* ignore that signal. 2340 * underlying ssh, it must *not* ignore that signal.
2338 */ 2341 */
2339 signal(SIGINT, SIG_IGN); 2342 ssh_signal(SIGINT, SIG_IGN);
2340 signal(SIGTERM, SIG_DFL); 2343 ssh_signal(SIGTERM, SIG_DFL);
2341 execvp(path, args); 2344 execvp(path, args);
2342 fprintf(stderr, "exec: %s: %s\n", path, strerror(errno)); 2345 fprintf(stderr, "exec: %s: %s\n", path, strerror(errno));
2343 _exit(1); 2346 _exit(1);
2344 } 2347 }
2345 2348
2346 signal(SIGTERM, killchild); 2349 ssh_signal(SIGTERM, killchild);
2347 signal(SIGINT, killchild); 2350 ssh_signal(SIGINT, killchild);
2348 signal(SIGHUP, killchild); 2351 ssh_signal(SIGHUP, killchild);
2349 signal(SIGTSTP, suspchild); 2352 ssh_signal(SIGTSTP, suspchild);
2350 signal(SIGTTIN, suspchild); 2353 ssh_signal(SIGTTIN, suspchild);
2351 signal(SIGTTOU, suspchild); 2354 ssh_signal(SIGTTOU, suspchild);
2352 signal(SIGCHLD, sigchld_handler); 2355 ssh_signal(SIGCHLD, sigchld_handler);
2353 close(c_in); 2356 close(c_in);
2354 close(c_out); 2357 close(c_out);
2355} 2358}