dangerous behaviour of scp

Darren Tucker dtucker at zip.com.au
Thu Dec 9 13:33:09 EST 2004

John Davidorff Pell wrote:
> Is scp ever sync'd with any updated, improved, bug-fixed rcp tree? I 
> know that some that the version of rcp included with Mac OS X is a 
> little diff, which I assume comes from freeBSD. Is it ever updated, or 
> is it one of those things that you just really want to leave alone and 
> never touch?

OpenSSH's scp is based on OpenBSD's rcp.  Typically any fixes get 
applied to both.

> Keeping scp almost identical to rcp is all well and good, but which 
> version of rcp? What about actual not-functionality-changing-bug-fixes?

BTW I think the fairest criticism is that it behaves differently for 
local vs remote copies (see below).

Anyway, it turns out that due to some work by Markus earlier this year, 
scp already knows if the destination should be a directory, so it's easy 
to fix, see attached patch.

Without patch:
$ touch a b
$ echo test >c
$ scp a b localhost:c
scp: c: Not a directory
$ scp -v a b c
Executing: exec cp a c
Executing: exec cp b c
$ ls -l c
-rw-rw-r--    1 dtucker  dtucker         0 Dec  9 12:54 c

With patch:
$ scp -v a b c
scp: c: Not a directory

Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
     Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: openssh-scp-dest-dir.patch
Url: http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20041209/1b30d4db/attachment.ksh 

More information about the openssh-unix-dev mailing list