]> andersk Git - gssapi-openssh.git/blobdiff - openssh/scp.c
Update to hpn12v20 from hpn12v18.
[gssapi-openssh.git] / openssh / scp.c
index 6c9dd4d41098a4cc76402d98ce49f5078c91a2bb..1c17f22c854e4a135d8fb6e1ebc7dabc3821c527 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.155 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: scp.c,v 1.160 2007/08/06 19:16:06 sobrado Exp $ */
 /*
  * scp - secure remote copy.  This is basically patched BSD rcp which
  * uses ssh to do the data transfer (instead of using rcmd).
@@ -96,6 +96,9 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
+#include <vis.h>
+#endif
 
 #include "xmalloc.h"
 #include "atomicio.h"
@@ -310,7 +313,7 @@ main(int argc, char **argv)
        addargs(&args, "-oClearAllForwardings yes");
 
        fflag = tflag = 0;
-       while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246zS:o:F:w:")) != -1)
+       while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1)
                switch (ch) {
                /* User-visible flags. */
                case '1':
@@ -318,7 +321,6 @@ main(int argc, char **argv)
                case '4':
                case '6':
                case 'C':
-               case 'z':       
                        addargs(&args, "-%c", ch);
                        break;
                case 'o':
@@ -372,9 +374,6 @@ main(int argc, char **argv)
                        setmode(0, O_BINARY);
 #endif
                        break;
-               case 'w':
-                       addargs(&args, "-w%s", optarg);
-                       break;
                default:
                        usage();
                }
@@ -384,7 +383,7 @@ main(int argc, char **argv)
        if ((pwd = getpwuid(userid = getuid())) == NULL)
                fatal("unknown user %u", (u_int) userid);
 
-       if (!isatty(STDERR_FILENO))
+       if (!isatty(STDOUT_FILENO))
                showprogress = 0;
 
        remin = STDIN_FILENO;
@@ -586,7 +585,7 @@ source(int argc, char **argv)
        off_t i, amt, statbytes;
        size_t result;
        int fd = -1, haderr, indx;
-       char *last, *name, buf[16384];
+       char *last, *name, buf[16384], encname[MAXPATHLEN];
        int len;
 
        for (indx = 0; indx < argc; ++indx) {
@@ -595,17 +594,17 @@ source(int argc, char **argv)
                len = strlen(name);
                while (len > 1 && name[len-1] == '/')
                        name[--len] = '\0';
+               if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0)
+                       goto syserr;
                if (strchr(name, '\n') != NULL) {
-                       run_err("%s: skipping, filename contains a newline",
-                           name);
-                       goto next;
+                       strnvis(encname, name, sizeof(encname), VIS_NL);
+                       name = encname;
                }
-               if ((fd = open(name, O_RDONLY, 0)) < 0)
-                       goto syserr;
                if (fstat(fd, &stb) < 0) {
 syserr:                        run_err("%s: %s", name, strerror(errno));
                        goto next;
                }
+               unset_nonblock(fd);
                switch (stb.st_mode & S_IFMT) {
                case S_IFREG:
                        break;
@@ -1025,7 +1024,8 @@ bad:                      run_err("%s: %s", np, strerror(errno));
                        wrerr = YES;
                        wrerrno = errno;
                }
-               if (wrerr == NO && ftruncate(ofd, size) != 0) {
+               if (wrerr == NO && (!exists || S_ISREG(stb.st_mode)) &&
+                   ftruncate(ofd, size) != 0) {
                        run_err("%s: truncate: %s", np, strerror(errno));
                        wrerr = DISPLAYED;
                }
@@ -1119,8 +1119,8 @@ usage(void)
 {
        (void) fprintf(stderr,
            "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
-           "           [-l limit] [-o ssh_option] [-P port] [-w buffer size] [-S program]\n"
-           "           [[user@]host1:]file1 [...] [[user@]host2:]file2\n");
+           "           [-l limit] [-o ssh_option] [-P port] [-S program]\n"
+           "           [[user@]host1:]file1 ... [[user@]host2:]file2\n");
        exit(1);
 }
 
This page took 0.036694 seconds and 4 git commands to generate.