sftpd: handle setstat requests with multiple attrs

This commit is contained in:
Nicola Murino 2021-11-24 11:55:14 +01:00
parent 9fb43b2c46
commit 531cb5b5a1
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -573,16 +573,22 @@ func (c *BaseConnection) SetStat(virtualPath string, attributes *StatAttributes)
}
pathForPerms := c.getPathForSetStatPerms(fs, fsPath, virtualPath)
if attributes.Flags&StatAttrTimes != 0 {
if err = c.handleChtimes(fs, fsPath, pathForPerms, attributes); err != nil {
return err
}
}
if attributes.Flags&StatAttrPerms != 0 {
return c.handleChmod(fs, fsPath, pathForPerms, attributes)
if err = c.handleChmod(fs, fsPath, pathForPerms, attributes); err != nil {
return err
}
}
if attributes.Flags&StatAttrUIDGID != 0 {
return c.handleChown(fs, fsPath, pathForPerms, attributes)
}
if attributes.Flags&StatAttrTimes != 0 {
return c.handleChtimes(fs, fsPath, pathForPerms, attributes)
if err = c.handleChown(fs, fsPath, pathForPerms, attributes); err != nil {
return err
}
}
if attributes.Flags&StatAttrSize != 0 {
@ -590,7 +596,7 @@ func (c *BaseConnection) SetStat(virtualPath string, attributes *StatAttributes)
return c.GetPermissionDeniedError()
}
if err := c.truncateFile(fs, fsPath, virtualPath, attributes.Size); err != nil {
if err = c.truncateFile(fs, fsPath, virtualPath, attributes.Size); err != nil {
c.Log(logger.LevelWarn, "failed to truncate path %#v, size: %v, err: %+v", fsPath, attributes.Size, err)
return c.GetFsError(fs, err)
}