[Bug 3431] New: scp truncates file when copying file over itself

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Wed May 11 08:19:00 AEST 2022


https://bugzilla.mindrot.org/show_bug.cgi?id=3431

            Bug ID: 3431
           Summary: scp truncates file when copying file over itself
           Product: Portable OpenSSH
           Version: v9.0p1
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P5
         Component: scp
          Assignee: unassigned-bugs at mindrot.org
          Reporter: christof.schmitt at us.ibm.com

With the new sftp based scp, using scp to copy a file over
itself, truncates that file:

Steps to Reproduce:

1. echo foo > /tmp/bar
2. scp /tmp/bar $(hostname):/tmp/bar
3. cat /tmp/bar

All data in that file is then lost.

This is a problem for scripts, e.g. cluster automation tools
that rely on the fact that a file /tmp/bar can be copied with
scp to all cluster nodes as /tmp/bar, including the node itself.

Changing this behavior is unexpected, and silently dropping the
data seems to be the worst possibly outcome.

In addition to scripts, admins might also be surprised that
copying files (maybe accidentally) to the same host, leaves those
files corrupted.

Would it be possible to change the behavior in this case?
Either explicitly returning an error, or finding a way
to preserve the data would be a better outcome.

https://lists.mindrot.org/pipermail/openssh-unix-dev/2022-February/040059.html
suggests that possibly the sftp server could use a temp file.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list