Bug 2067 - lsetstat extension to sftp-server
Summary: lsetstat extension to sftp-server
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 6.1p1
Hardware: Other Other
: P5 enhancement
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks: V_8_0
  Show dependency treegraph
 
Reported: 2013-02-02 00:16 AEDT by Bert Haverkamp
Modified: 2021-04-23 15:01 AEST (History)
5 users (show)

See Also:


Attachments
Patch for sftp-server to add lsetstat extension (5.00 KB, patch)
2013-02-02 00:16 AEDT, Bert Haverkamp
no flags Details | Diff
Patch to sftp to add touch [-h] command (3.31 KB, patch)
2013-02-02 00:17 AEDT, Bert Haverkamp
no flags Details | Diff
sftp-server lsetstat extension, sftp client chmod/chgrp/chown -h flag (10.62 KB, patch)
2019-01-04 15:46 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bert Haverkamp 2013-02-02 00:16:28 AEDT
Created attachment 2212 [details]
Patch for sftp-server to add lsetstat extension

At the moment sftp is not able to set timestamps on symlinks.
In order to make this possible lsetstat needs to be implemented.
Attached patch makes this addition.

Some background info. I want to run dirvish over sshfs in order to make daily remote snapshot-backups. Currently rsync (which is used by dirvish) reports an error when updating the timestamp of a symlink. This in turn makes dirvish abort the backup.

In cooperation with Miklos Szeredi, the author of sshfs, I have created attached patch. He has created the functionality in sshfs to make use of this lsetstat extenstion in sftp. I've used this patch for 5 months now and it behaves perfectly. Dirvish creates complete backups every day now.

I have also created a patch for the sftp client-side to implement a "touch [-h]" command. This command makes it possible to update the utime of a symlink. It was mostly used to test above functionality, but will be handy in more cases. I will add this patch here too.
Comment 1 Bert Haverkamp 2013-02-02 00:17:33 AEDT
Created attachment 2213 [details]
Patch to sftp to add touch [-h] command
Comment 2 Bert Haverkamp 2014-04-09 21:43:59 AEST
Can someone please take a look to this patch? I have been using it in my system for over a year now. I'd love to have it included. Or at least reviewed;-)
Comment 3 Bert Haverkamp 2016-03-21 20:37:30 AEDT
Hopefully someone can take this patch into openssh?
I am running this happily for a long time now. But recompiling with every  upgrade is a hassle..
Comment 4 A. James Lewis 2017-07-13 11:28:01 AEST
I'm afraid I don't have much to add, other than to say that the OP is not the only person with this issue, I know at least one person who has been lamenting the lack of this feature for some time.... I guess not everyone is prepared to create an account to add their support!
Comment 5 Julien Picalausa 2019-01-03 01:32:08 AEDT
I just want to +1 this. Also, I want to point out that this seem like the root cause of an issue with extracting tar archives when using sshfs. In short, if a symlink gets extracted before its target, when tar attempts to set the time for that symlink, it fails because the target of the symlink doesn't (yet) exist, causing tar itself to report an error. This results for instance in steam failing to install its runtime when running from a home folder mounted over sshfs.

I haven't looked at the patch proposed here, so I can't vouch for it, but lsetstat seem to be a very much needed feature, especially in a world where sshfs is becoming a popular way to mount remote folders.
Comment 6 Damien Miller 2019-01-04 15:46:54 AEDT
Created attachment 3219 [details]
sftp-server lsetstat extension, sftp client chmod/chgrp/chown -h flag

This implements the lsetstat@openssh.com extension in the server, with a few more Attrib fields supported than the previous patches here.

On the client side, it adds a -h to the chown, chmod and chgrp command to give them no-dereference semantics.
Comment 7 Darren Tucker 2019-01-04 18:38:04 AEDT
Comment on attachment 3219 [details]
sftp-server lsetstat extension, sftp client chmod/chgrp/chown -h flag

>-	sshbuf_reset(msg);

these look like unrelated cleanup and should probably be a separate commit.  other than that, ok dtucker
Comment 8 Damien Miller 2019-01-17 11:07:25 AEDT
This has been committed and will be in openssh-8.0.

I haven't committed the "touch" command for sftp, but if you have a good use case for it then I can consider it.
Comment 9 Bert Haverkamp 2019-01-17 23:22:36 AEDT
Thanks for including this lsetstat extention patch in V8.0!

I have no personal usecase for the touch command. I added it as it is a logical addition, based on the added hardlink functionality. It would be a shame to leave it out, as it is very low-impact.
Comment 10 Damien Miller 2021-04-23 15:01:30 AEST
closing resolved bugs as of 8.6p1 release