Skip to content

expose the SSH_FXP_READDIR longname#657

Open
mickael-kerjean wants to merge 1 commit into
pkg:masterfrom
mickael-kerjean:master
Open

expose the SSH_FXP_READDIR longname#657
mickael-kerjean wants to merge 1 commit into
pkg:masterfrom
mickael-kerjean:master

Conversation

@mickael-kerjean

Copy link
Copy Markdown

Each entry in a SSH_FXP_NAME reply carries three fields: filename, longname and attrs (source). The client currently ignore the longname field with:

_, data = unmarshalString(data) // discard longname

I have a use case which require to display things similarly to what the open ssh cli shows:

sftp> ls -l
drwxrwxr-x    ? mickael  mickael      4096 Jul  3 18:34 Android
drwxr-xr-x    ? mickael  mickael      4096 Jun  3 00:03 Desktop
drwxr-xr-x    ? mickael  mickael      4096 Jul  8 14:14 Documents

As of today, this is not possible and this PR fixes that

Comment thread attrs.go
UID uint32
GID uint32
Extended []StatExtended
Longname string

@puellanivis puellanivis Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

longname is not a part of this structure, it’s a part of the SSH_FXP_NAME name entry sub-structure: https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-7

If you have need to access this and want to get it added in, it should be put in the fileInfo struct:

sftp/attrs.go

Lines 23 to 26 in fc82c35

type fileInfo struct {
name string
stat *FileStat
}
and then we can expose a LongName() string receiver method that you can then test with .(interface{ LongName() string }) to use it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants