=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/scp.c,v retrieving revision 1.108.2.2 retrieving revision 1.109 diff -u -r1.108.2.2 -r1.109 --- src/usr.bin/ssh/scp.c 2004/08/19 22:37:32 1.108.2.2 +++ src/usr.bin/ssh/scp.c 2003/09/19 17:40:20 1.109 @@ -71,7 +71,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.108.2.2 2004/08/19 22:37:32 brad Exp $"); +RCSID("$OpenBSD: scp.c,v 1.109 2003/09/19 17:40:20 markus Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -88,7 +88,7 @@ arglist args; /* Bandwidth limit */ -off_t limit_rate = 0; +off_t limit = 0; /* Name of current file being transferred. */ char *curfile; @@ -251,7 +251,7 @@ speed = strtod(optarg, &endp); if (speed <= 0 || *endp != '\0') usage(); - limit_rate = speed * 1024; + limit = speed * 1024; break; case 'p': pflag = 1; @@ -267,7 +267,6 @@ verbose_mode = 1; break; case 'q': - addargs(&args, "-q"); showprogress = 0; break; @@ -580,7 +579,7 @@ haderr = result >= 0 ? EIO : errno; statbytes += result; } - if (limit_rate) + if (limit) bwlimit(amt); } if (showprogress) @@ -654,7 +653,7 @@ { static struct timeval bwstart, bwend; static int lamt, thresh = 16384; - u_int64_t waitlen; + u_int64_t wait; struct timespec ts, rm; if (!timerisset(&bwstart)) { @@ -672,10 +671,10 @@ return; lamt *= 8; - waitlen = (double)1000000L * lamt / limit_rate; + wait = (double)1000000L * lamt / limit; - bwstart.tv_sec = waitlen / 1000000L; - bwstart.tv_usec = waitlen % 1000000L; + bwstart.tv_sec = wait / 1000000L; + bwstart.tv_usec = wait % 1000000L; if (timercmp(&bwstart, &bwend, >)) { timersub(&bwstart, &bwend, &bwend); @@ -750,8 +749,6 @@ *cp++ = ch; } while (cp < &buf[sizeof(buf) - 1] && ch != '\n'); *cp = 0; - if (verbose_mode) - fprintf(stderr, "Sink: %s", buf); if (buf[0] == '\01' || buf[0] == '\02') { if (iamremote == 0) @@ -815,10 +812,6 @@ size = size * 10 + (*cp++ - '0'); if (*cp++ != ' ') SCREWUP("size not delimited"); - if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) { - run_err("error: unexpected filename: %s", cp); - exit(1); - } if (targisdir) { static char *namebuf; static int cursize; @@ -840,8 +833,6 @@ exists = stat(np, &stb) == 0; if (buf[0] == 'D') { int mod_flag = pflag; - if (!iamrecursive) - SCREWUP("received directory without -r"); if (exists) { if (!S_ISDIR(stb.st_mode)) { errno = ENOTDIR; @@ -893,8 +884,11 @@ amt = size - i; count += amt; do { - j = atomicio(read, remin, cp, amt); - if (j <= 0) { + j = read(remin, cp, amt); + if (j == -1 && (errno == EINTR || + errno == EAGAIN)) { + continue; + } else if (j <= 0) { run_err("%s", j ? strerror(errno) : "dropped connection"); exit(1); @@ -903,8 +897,8 @@ cp += j; statbytes += j; } while (amt > 0); - - if (limit_rate) + + if (limit) bwlimit(4096); if (count == bp->cnt) { @@ -933,18 +927,14 @@ } if (pflag) { if (exists || omode != mode) - if (fchmod(ofd, omode)) { + if (fchmod(ofd, omode)) run_err("%s: set mode: %s", np, strerror(errno)); - wrerr = DISPLAYED; - } } else { if (!exists && omode != mode) - if (fchmod(ofd, omode & ~mask)) { + if (fchmod(ofd, omode & ~mask)) run_err("%s: set mode: %s", np, strerror(errno)); - wrerr = DISPLAYED; - } } if (close(ofd) == -1) { wrerr = YES; @@ -1012,8 +1002,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] [-S program]\n" + "usage: scp [-pqrvBC1246] [-F config] [-S program] [-P port]\n" + " [-c cipher] [-i identity] [-l limit] [-o option]\n" " [[user@]host1:]file1 [...] [[user@]host2:]file2\n"); exit(1); }