Bug 882 - Scp cannot copy self-referring directories
Summary: Scp cannot copy self-referring directories
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: scp (show other bugs)
Version: 3.8p1
Hardware: All Linux
: P2 major
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-23 16:00 AEST by M. Creidieki Crouch
Modified: 2004-09-11 13:18 AEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M. Creidieki Crouch 2004-06-23 16:00:10 AEST
Hi,

I was trying to copy a directory from my school web space, and there was a link
in the directory that led back to the directory itself.  When I tried to scp
this directory to my home computer, scp tried to create an infinite number of
copies of the directory!  It was someone else's directory, so I couldn't just
delete the link.  The directory worked fine with "cp -r", but not with "scp -r".

I could provide a sample of this kind of directory if that would be helpful.

Thanks!
Comment 1 Darren Tucker 2004-06-23 16:07:04 AEST
Is that "link" or "symlink"?  Hard links to directories are usually the result
(or cause!) of filesystem corruption.

Show us what it your directory and its link looks like (eg ls -l).
Comment 2 M. Creidieki Crouch 2004-06-27 11:57:34 AEST
The offending file is named "suzuki".  When I "ls -l suzuki" in the directory,
it tells me

"
lrwxr-xr-x    1 8779     staff           1 May 18  1994 suzuki -> .
"

Thanks.
Comment 3 Darren Tucker 2004-07-01 10:50:55 AEST
Right now, scp does not understand symlinks at all, and afaict having it
understand them enough to be able to copy them (like "rsync -l") would require a
protocol change (which is not going to happen).

Maybe we could add an option to scp to skip links ("scp -l" ?)  Opinions?
Comment 4 M. Creidieki Crouch 2004-07-01 13:02:18 AEST
That seems odd, consider that symlinks are so widely used.  I haven't been able
to find a copy of the SCP protocol online, but I'd be interested in taking a
look at it, and making suggestions for how it could be extended.  Do you know
where there's a copy?
Comment 5 Ben Lindstrom 2004-07-01 13:05:55 AEST
SCP is just the old 'rcp'  but uses the ssh instead of rsh for the tunnel.  And rcp was never really 
documnted outside of the source.

I don't for see us 'extending' this anytime soon.  scp is really just for legacy support to help those that 
are migrating to ssh.

sftp is an RFC standard protocol and all work should be done on that.
Comment 6 Damien Miller 2004-07-01 13:09:10 AEST
(Ben beat me to this, but I'll add my voice anyway)

There is no specification of the scp protocol, it is just rcp over ssh.

We aren't interested in extending it at all: it is very widely deployed, 
undocumented, 20+ year old protocol with uncorrectable flaws and no versioning 
or migration mechanism.

It is better to improve the tools of the sftp (draft-ietf-secsh-filexfer-*) 
protocol instead. This protocol fixes all of the above flaws and includes the 
ability to recognise and transfer symlinks. Our sftp tools aren't as complete as 
the scp ones (in particular, there are no recursive commands yet), but that can 
be rectified :)
Comment 7 M. Creidieki Crouch 2004-07-01 13:16:00 AEST
*nod* I hadn't really looked at sftp; that makes sense.  Do you expect that
scp's functionality will eventually be replaced by command-line arguments to
sftp?  I think it's very convenient to be able to use scp to copy things quickly.
Comment 8 Darren Tucker 2004-07-01 13:19:56 AEST
Basically, the spec for scp is "what rcp does", and the spec for rcp is "what
some guys at Berkeley wrote in the early 80's".  rcp might even predate the
existence of symlinks.

Like Ben says, the closest thing to a spec for scp is "scp.c".

Suggested workarounds:
1) Don't do that, then.
2) Use tar-over-ssh or rsync-over-ssh to transfer it link and all, eg:
ssh yourhost 'tar cf - dir-to-copy' | tar xvf -
3) Use sftp (it doesn't do recursive yet, one day it will).
Comment 9 Damien Miller 2004-07-01 13:35:02 AEST
Yes, there is even an open bug for this: Bug #634