From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 Red Hat/1.7.12-1.1.3.2 Description of problem: When copying several files, the last one must be a directory, but if the last one is a file, scp will overwrite it. This example explains it well. Here's something to try: $ echo a >a $ echo b >b $ echo c >c $ $ scp a b c $ $ echo $? 1 $ cat a b c a b b Ouch! Also, for comparison: $ cp a b c cp: copying multiple files, but last argument `c' is not a directory Try `cp --help' for more information. $ rcp a b c rcp: c: Not a directory. $ Note that the cp behavior is specified in SuSv2. (http://www.opengroup.org/onlinepubs/007908799/xcu/cp.html, "Second synopsis") Also, and this might be a separate bug, note how openssh exits with return code of 1. Note: This also happens to the current version of openssh in RHEL 3 (openssh-3.6.1p2-33.30.6) I have a patch for your review as well, I'll attach it. /August. Version-Release number of selected component (if applicable): openssh-3.9p1-8.RHEL4.9 How reproducible: Always Steps to Reproduce: 1. See example above in the "Description" field. 2. 3. Actual Results: Data loss. Expected Results: An error message, and no lost data. Additional info: I mailed this to the openssh-unix-dev mailing list, archived at http://marc.theaimsgroup.com/?t=113776318200001&r=1&w=2
Created attachment 123674 [details] Patch against 4.2p1 Here's a patch that seems to fix it. Against 4.2p1 (but it's not exactly a super advanced patch, so it should be readily portable.) The first chunk fixed the eating of the innocent file, and is fairly obvoiusly correct. The second one fixes the fact that there's no error message. I'm less certain of that one not breaking anything else. (A colleague wrote that one... :) /August.
This is from source-changes.org, apparently the fix is in upstream. /August. Date: Tue, 31 Jan 2006 03:35:43 -0700 (MST) Subject: CVS: cvs.openbsd.org: src CVSROOT: /cvs Module name: src Changes by: djm.org 2006/01/31 03:35:43 Modified files: usr.bin/ssh : scp.c Log message: "scp a b c" shouldn't clobber "c" when it is not a directory, report and fix from biorn@; ok markus@
This issue is on Red Hat Engineering's list of planned work items for the upcoming Red Hat Enterprise Linux 4.4 release. Engineering resources have been assigned and barring unforeseen circumstances, Red Hat intends to include this item in the 4.4 release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2006-0303.html