Subject: preserving access and modification time (was Re: libssh2_scp_send64: incorrect/unspecific error message)

preserving access and modification time (was Re: libssh2_scp_send64: incorrect/unspecific error message)

From: Uli Zappe <uli_at_ritual.org>
Date: Fri, 10 Sep 2010 09:46:47 +0200

Am 10.09.2010 um 08:34 schrieb Daniel Stenberg:

> On Fri, 10 Sep 2010, Uli Zappe wrote:
>
>> So, the only explanation seems to be that while "T1111111111 0 1111111111 0" is indeed sent, it's somehow "misformatted" so that it doesn't achieve the intended effect. Unfortunately, I dont' know anything about the ssh/scp protocol, so I cannot judge that.
>
> None of us knew the protocol until we looked it up and learned it. Try:
>
> http://blogs.sun.com/janp/entry/how_the_scp_protocol_works

Thanks for the link, very nice!

> To me it seems the times are sent correctly...

Well, interestingly the linked article describes several scenarios, but notably exactly what is the issue at hand is missing: preserving the modification time when you copy a file *to* the remote side. (Copying *from* the remote host preserves the time just fine for me in the examples of the article, and in libssh2, too.)

Now, of course you would think that the time preserving examples of the linked article would work as well the other way round, i.e. doing something like

$ scp -pt /tmp
$ T1183832947 0 1183833773 0
$ C0644 6 test
$ [content]

However, this does *not* work; it doesn't affect the modification time at all (I also tried scp -p -t without success, just to make sure). Since this seems to be exactly what libssh2 does, it's no wonder that this doesn't work, either.

In contrast, using (OpenSSH's) scp in a "regular" way (scp -p source target) works just fine. So there are two obvious questions:

1. What is it (at least on Mac OS X) that OpenSSH at the remote end expects that the above usage (scp -pt /tmp ...) does not deliver, but the "regular" use of scp (scp -p source target) does?

2. Is this a peculiarity of Mac OS X's version of OpenSSH? I very much doubt it, but it would be good to cross-check with OpenSSH on Linux & Co, to make sure it is as basic a problem as it seems to be.

            Bye
                    Uli
________________________________________________________

  Uli Zappe, Solmsstraße 5, D-65189 Wiesbaden, Germany
  http://www.ritual.org
  Fon: +49-700-ULIZAPPE
  Fax: +49-700-ZAPPEFAX
________________________________________________________

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-09-10