sftpd: add lstat support

This commit is contained in:
Nicola Murino
2020-09-11 09:30:25 +02:00
parent 01850c7399
commit 61003c8079
5 changed files with 82 additions and 36 deletions

View File

@@ -238,6 +238,28 @@ func (c *Connection) Filelist(request *sftp.Request) (sftp.ListerAt, error) {
}
}
// Lstat implements LstatFileLister interface
func (c *Connection) Lstat(request *sftp.Request) (sftp.ListerAt, error) {
c.UpdateLastActivity()
p, err := c.Fs.ResolvePath(request.Filepath)
if err != nil {
return nil, c.GetFsError(err)
}
if !c.User.HasPerm(dataprovider.PermListItems, path.Dir(request.Filepath)) {
return nil, sftp.ErrSSHFxPermissionDenied
}
s, err := c.DoStat(p, 1)
if err != nil {
c.Log(logger.LevelDebug, "error running lstat on path %#v: %+v", p, err)
return nil, c.GetFsError(err)
}
return listerAt([]os.FileInfo{s}), nil
}
func (c *Connection) getSFTPCmdTargetPath(requestTarget string) (string, error) {
var target string
// If a target is provided in this request validate that it is going to the correct