scp: Problem when source and destination are identical
Markus Friedl
markus.friedl at informatik.uni-erlangen.de
Sat May 19 05:42:13 EST 2001
this restores the rcp behaviour.
Index: scp.c
===================================================================
RCS file: /home/markus/cvs/ssh/scp.c,v
retrieving revision 1.70
diff -U10 -r1.70 scp.c
--- scp.c 2001/05/08 19:45:24 1.70
+++ scp.c 2001/05/18 19:38:58
@@ -770,21 +770,21 @@
vect[0], strerror(errno));
}
if (mod_flag)
(void) chmod(vect[0], mode);
if (vect[0])
xfree(vect[0]);
continue;
}
omode = mode;
mode |= S_IWRITE;
- if ((ofd = open(np, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0) {
+ if ((ofd = open(np, O_WRONLY | O_CREAT , mode)) < 0) {
bad: run_err("%s: %s", np, strerror(errno));
continue;
}
(void) atomicio(write, remout, "", 1);
if ((bp = allocbuf(&buffer, ofd, 4096)) == NULL) {
(void) close(ofd);
continue;
}
cp = bp->buf;
wrerr = NO;
@@ -825,21 +825,21 @@
cp = bp->buf;
}
}
if (showprogress)
progressmeter(1);
if (count != 0 && wrerr == NO &&
(j = atomicio(write, ofd, bp->buf, count)) != count) {
wrerr = YES;
wrerrno = j >= 0 ? EIO : errno;
}
-#if 0
+#if 1
if (ftruncate(ofd, size)) {
run_err("%s: truncate: %s", np, strerror(errno));
wrerr = DISPLAYED;
}
#endif
if (pflag) {
if (exists || omode != mode)
if (fchmod(ofd, omode))
run_err("%s: set mode: %s",
np, strerror(errno));
More information about the openssh-unix-dev
mailing list