Skip to content

Add support for extension lsetstat@openssh.com #651

Open

Description

@quite

This extension is for doing chmod, chtimes, and chown on symlinks. That is on the actual symlink, not on what it points to. See https://github.com/openssh/openssh-portable/blob/master/PROTOCOL#L508

Good insights from @puellanivis in #648 (comment):

I would definitely suggest going for targeting v2 for extensions. I already have quite a few, but I hadn’t seen this lsetstat@openssh.com one yet.

Probably need to think on how I expect an extended type request gets sent. sftp.Client should probably support it through a direct LSetStat call… or rather the various chown chtimes etc should have an L prefix varient.

Though utimensat isn’t going to be possible, even lsetstat@openssh.com only has second precision through the File Attributes specification.

I got utimensat from reading the openssh sftp-server implementation. But yeah, the fact that it uses utimensat to set it, does not mean that there is ns (nanosecond) precision in the protocol on the wire.

Openssh's sftp-server here: https://github.com/openssh/openssh-portable/blob/master/sftp-server.c#L1460

Activity

  1. christhomas commented on Oct 17, 2026

    @christhomas
    Contributor

    I'd like to pick this up for v2. The lsetstat@openssh.com packet is already in encoding/ssh/filexfer/openssh (#656), so what's left is the client and server side. Which client API would you prefer: L-prefixed variants (Lchmod, Lchown, Lchtimes), a single LSetStat(name, attrs), or both?

    I've started with the L-prefixed variants, since that's what you suggested in #648, but it's easy to switch. On the server side I've added an extension interface like HardlinkServerHandler, advertised when the handler implements it, and implemented it in localfs as far as the platform allows (Linux can't change a symlink's mode, for example).

  2. quite commented on Oct 18, 2026

    @quite
    Author

    I don't have resource to page in the whole context of this again. But it sounds like multiple Lch* makes sense, as that would matches existing Ch* client functions, right?

  3. christhomas commented on Oct 18, 2026

    @christhomas
    Contributor

    That would seem more consistent yeah, Ch* and Lch*, thats consistent

  4. christhomas commented on Oct 18, 2026

    @christhomas
    Contributor

    Updated #684 to reflect the agreement here: the client API uses Lchmod, Lchown and Lchtimes, matching the existing Chmod/Chown/Chtimes methods. The implementation already provides these methods, so this update only changes the PR description: it links to the decision and removes the open question about offering a single LSetStat method.

  5. puellanivis commented on Oct 18, 2026

    @puellanivis
    Collaborator

    Everything is solid argument here except we’ve switched to prefixes being separate words. So, LChmod, LChown, and LChtimes.

  6. christhomas commented on Oct 18, 2026

    @christhomas
    Contributor

    Done: #684 now uses LChmod, LChown and LChtimes (da648b8), and the PR description is updated to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions