pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.5k stars 379 forks source link

uid/gid from fs.FileInfo #518

Closed desdic closed 2 years ago

desdic commented 2 years ago

I'm trying to get the uid/gid (from a Linux server) but when trying it doesn't seem to work

        if stat, ok := fileinfo.Sys().(*syscall.Stat_t); ok {
                uid = int(stat.Uid)
                gid = int(stat.Gid)
                inode = stat.Ino
        }

I can see from the implementation that Attributes should be available but I cannot figure out how to get to them

puellanivis commented 2 years ago

The type is not *syscall.Stat_t try seeing if this type works for you: https://github.com/pkg/sftp/blob/v1.13.5/attrs.go#L45-L57

I’m still not entirely sure it will work, I was in the middle of rewriting all the client stuff when I got sidetracked with other (paid) stuff.

desdic commented 2 years ago

Well I haven't tried to look for the inode yet but I can tell you that the UID/GID works perfectly .. thank you!