Bug 178923 - Locally copying several files to non-directory "works".
Summary: Locally copying several files to non-directory "works".
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: openssh
Version: 4.0
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
: ---
Assignee: Tomas Mraz
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 181409
TreeView+ depends on / blocked
 
Reported: 2006-01-25 15:18 UTC by Björn Augustsson
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version: RHBA-2006-0303
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-08-10 21:19:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch against 4.2p1 (1.13 KB, patch)
2006-01-25 15:28 UTC, Björn Augustsson
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0303 0 normal SHIPPED_LIVE openssh bug fix update 2006-08-09 04:00:00 UTC

Description Björn Augustsson 2006-01-25 15:18:29 UTC
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

Comment 1 Björn Augustsson 2006-01-25 15:28:32 UTC
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.

Comment 2 Björn Augustsson 2006-02-01 17:00:37 UTC
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@


Comment 3 Bob Johnson 2006-04-11 17:16:18 UTC
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.

Comment 7 Red Hat Bugzilla 2006-08-10 21:19:21 UTC
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



Note You need to log in before you can comment on or make changes to this bug.