summaryrefslogtreecommitdiff
path: root/scp.c
diff options
context:
space:
mode:
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/scp.c b/scp.c
index 3b7ca5a8d..0b483df99 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.164 2008/10/10 04:55:16 stevesk Exp $ */ 1/* $OpenBSD: scp.c,v 1.165 2009/12/20 07:28:36 guenther Exp $ */
2/* 2/*
3 * scp - secure remote copy. This is basically patched BSD rcp which 3 * scp - secure remote copy. This is basically patched BSD rcp which
4 * uses ssh to do the data transfer (instead of using rcmd). 4 * uses ssh to do the data transfer (instead of using rcmd).
@@ -252,8 +252,11 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
252 close(pout[1]); 252 close(pout[1]);
253 253
254 replacearg(&args, 0, "%s", ssh_program); 254 replacearg(&args, 0, "%s", ssh_program);
255 if (remuser != NULL) 255 if (remuser != NULL) {
256 addargs(&args, "-l%s", remuser); 256 addargs(&args, "-l");
257 addargs(&args, "%s", remuser);
258 }
259 addargs(&args, "--");
257 addargs(&args, "%s", host); 260 addargs(&args, "%s", host);
258 addargs(&args, "%s", cmd); 261 addargs(&args, "%s", cmd);
259 262
@@ -345,10 +348,12 @@ main(int argc, char **argv)
345 case 'c': 348 case 'c':
346 case 'i': 349 case 'i':
347 case 'F': 350 case 'F':
348 addargs(&args, "-%c%s", ch, optarg); 351 addargs(&args, "-%c", ch);
352 addargs(&args, "%s", optarg);
349 break; 353 break;
350 case 'P': 354 case 'P':
351 addargs(&args, "-p%s", optarg); 355 addargs(&args, "-p");
356 addargs(&args, "%s", optarg);
352 break; 357 break;
353 case 'B': 358 case 'B':
354 addargs(&args, "-oBatchmode yes"); 359 addargs(&args, "-oBatchmode yes");
@@ -556,6 +561,7 @@ toremote(char *targ, int argc, char **argv)
556 } else { 561 } else {
557 host = cleanhostname(argv[i]); 562 host = cleanhostname(argv[i]);
558 } 563 }
564 addargs(&alist, "--");
559 addargs(&alist, "%s", host); 565 addargs(&alist, "%s", host);
560 addargs(&alist, "%s", cmd); 566 addargs(&alist, "%s", cmd);
561 addargs(&alist, "%s", src); 567 addargs(&alist, "%s", src);
@@ -566,7 +572,7 @@ toremote(char *targ, int argc, char **argv)
566 errs = 1; 572 errs = 1;
567 } else { /* local to remote */ 573 } else { /* local to remote */
568 if (remin == -1) { 574 if (remin == -1) {
569 xasprintf(&bp, "%s -t %s", cmd, targ); 575 xasprintf(&bp, "%s -t -- %s", cmd, targ);
570 host = cleanhostname(thost); 576 host = cleanhostname(thost);
571 if (do_cmd(host, tuser, bp, &remin, 577 if (do_cmd(host, tuser, bp, &remin,
572 &remout) < 0) 578 &remout) < 0)
@@ -599,6 +605,7 @@ tolocal(int argc, char **argv)
599 addargs(&alist, "-r"); 605 addargs(&alist, "-r");
600 if (pflag) 606 if (pflag)
601 addargs(&alist, "-p"); 607 addargs(&alist, "-p");
608 addargs(&alist, "--");
602 addargs(&alist, "%s", argv[i]); 609 addargs(&alist, "%s", argv[i]);
603 addargs(&alist, "%s", argv[argc-1]); 610 addargs(&alist, "%s", argv[argc-1]);
604 if (do_local_cmd(&alist)) 611 if (do_local_cmd(&alist))
@@ -618,7 +625,7 @@ tolocal(int argc, char **argv)
618 suser = pwd->pw_name; 625 suser = pwd->pw_name;
619 } 626 }
620 host = cleanhostname(host); 627 host = cleanhostname(host);
621 xasprintf(&bp, "%s -f %s", cmd, src); 628 xasprintf(&bp, "%s -f -- %s", cmd, src);
622 if (do_cmd(host, suser, bp, &remin, &remout) < 0) { 629 if (do_cmd(host, suser, bp, &remin, &remout) < 0) {
623 (void) xfree(bp); 630 (void) xfree(bp);
624 ++errs; 631 ++errs;