Christian Kurz
2001-Jan-30 07:27 UTC
Detection of identical file doesn't work for localhost:
Hi, I had to notice that scp is able to detect if a file is copied to itself if you use "scp foo /path/to/foo" or "scp foo .". If you type in "scp foo localhost:/path/to/foo" it will still overwrite the old version of foo. Is it possible to change this behaviour of scp? I only had a quick glance at scp.c and I'm also not a C coder, only learning C right now, so please give me some hints if I'm wrong. You use the function "colon" in 984 to check if you should to a remote copy or a local copy. I think it would be possible to add a check to it to see if the name of the remote host will be localhost and then also use the function "tolocal" for doing a local copy instead of calling "toremote". What do you guys think? Would you please add this feature? Ciao Christian P.S.: Would somebody please change s/debain/debian/ in the ChangeLog to fix my email-address? Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 242 bytes Desc: not available Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20010130/d87d034d/attachment.bin
Gert Doering
2001-Jan-30 09:06 UTC
Detection of identical file doesn't work for localhost:
Hi, On Tue, Jan 30, 2001 at 08:27:49AM +0100, Christian Kurz wrote:> I had to notice that scp is able to detect if a file is copied to itself > if you use "scp foo /path/to/foo" or "scp foo .". If you type in "scp > foo localhost:/path/to/foo" it will still overwrite the old version of > foo. Is it possible to change this behaviour of scp? > > I only had a quick glance at scp.c and I'm also not a C coder, only > learning C right now, so please give me some hints if I'm wrong. You use > the function "colon" in 984 to check if you should to a remote copy or a > local copy. I think it would be possible to add a check to it to see if > the name of the remote host will be localhost and then also use the > function "tolocal" for doing a local copy instead of calling "toremote". > What do you guys think? Would you please add this feature?I don't think it's reasonable. If a user want to shoot into his own foot, he will always be able to do this. If you trap "localhost", people will use 127.0.0.1, or the real name of the machine, or one of its ethernet IP addresses, etc. (Why on earth would anybody do an "scp localhost:..." in the first place?) gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany gert at greenie.muc.de fax: +49-89-35655025 gert.doering at physik.tu-muenchen.de
Damien Miller
2001-Jan-30 09:06 UTC
Detection of identical file doesn't work for localhost:
On Tue, 30 Jan 2001, Christian Kurz wrote:> Hi, > > I had to notice that scp is able to detect if a file is copied to itself > if you use "scp foo /path/to/foo" or "scp foo .". If you type in "scp > foo localhost:/path/to/foo" it will still overwrite the old version of > foo. Is it possible to change this behaviour of scp? > > I only had a quick glance at scp.c and I'm also not a C coder, only > learning C right now, so please give me some hints if I'm wrong. You use > the function "colon" in 984 to check if you should to a remote copy or a > local copy. I think it would be possible to add a check to it to see if > the name of the remote host will be localhost and then also use the > function "tolocal" for doing a local copy instead of calling "toremote". > What do you guys think? Would you please add this feature?This has come up before, IIRC we decided not to put such a check in because there are so many ways to refer to the local host (localhost, hostname(s), ip addresses, etc) that such a check would cover a small range of the cases. OTOH a patch to make scp write to a temp file and then rename it as the final step may make more sense and achieve a better result.> P.S.: Would somebody please change s/debain/debian/ in the ChangeLog to > fix my email-address? ThanksDone. -d -- | ``We've all heard that a million monkeys banging on | Damien Miller - | a million typewriters will eventually reproduce the | <djm at mindrot.org> | works of Shakespeare. Now, thanks to the Internet, / | we know this is not true.'' - Robert Wilensky UCB / http://www.mindrot.org
Markus Friedl
2001-Jan-30 10:44 UTC
Detection of identical file doesn't work for localhost:
> I had to notice that scp is able to detect if a file is copied to itself > if you use "scp foo /path/to/foo" or "scp foo .". If you type in "scp > foo localhost:/path/to/foo" it will still overwrite the old version of > foo. Is it possible to change this behaviour of scp?how could 'scp' tell that it's really the identical file?
Darren Moffat
2001-Jan-30 17:32 UTC
Detection of identical file doesn't work for localhost:
>>(Why on earth would anybody do an "scp localhost:..." in the first place?) > >Why? Well, one reason would be to copy from a chroot()ed environment >back to the real host, of course... Probably not, but it is possible. >There is no guarentee that localhost:/some/directory is in the same >filesystem as /some/directory on the current machine as viewed by >the currently running scp program.But if that is the case then the reported problem doesn't occur because the source and destination are different. A check like this is likely to do more harm than good, just to fix one or two edge cases where the user did something strange and didn't like what they got. -- Darren J Moffat