sftpd: add Readlink support

This commit is contained in:
Nicola Murino
2020-08-22 14:52:17 +02:00
parent 5208e4a4ca
commit 02e35ee002
16 changed files with 183 additions and 38 deletions

View File

@@ -56,7 +56,7 @@ func (fs OsFs) Stat(name string) (os.FileInfo, error) {
}
for _, v := range fs.virtualFolders {
if v.MappedPath == name {
info := NewFileInfo(v.VirtualPath, true, fi.Size(), fi.ModTime())
info := NewFileInfo(v.VirtualPath, true, fi.Size(), fi.ModTime(), false)
return info, nil
}
}
@@ -71,7 +71,7 @@ func (fs OsFs) Lstat(name string) (os.FileInfo, error) {
}
for _, v := range fs.virtualFolders {
if v.MappedPath == name {
info := NewFileInfo(v.VirtualPath, true, fi.Size(), fi.ModTime())
info := NewFileInfo(v.VirtualPath, true, fi.Size(), fi.ModTime(), false)
return info, nil
}
}
@@ -116,6 +116,16 @@ func (OsFs) Symlink(source, target string) error {
return os.Symlink(source, target)
}
// Readlink returns the destination of the named symbolic link
// as absolute virtual path
func (fs OsFs) Readlink(name string) (string, error) {
p, err := os.Readlink(name)
if err != nil {
return p, err
}
return fs.GetRelativePath(p), err
}
// Chown changes the numeric uid and gid of the named file.
func (OsFs) Chown(name string, uid int, gid int) error {
return os.Chown(name, uid, gid)