Ensure a file uploaded using SFTP is properly owned at the end; closes pterodactyl/panel#3689

This commit is contained in:
Dane Everitt 2022-01-23 13:14:02 -05:00
parent 4c8f5c21a3
commit 301788805c

View File

@ -119,6 +119,9 @@ func (h *Handler) Filewrite(request *sftp.Request) (io.WriterAt, error) {
l.WithField("flags", request.Flags).WithField("error", err).Error("failed to open existing file on system") l.WithField("flags", request.Flags).WithField("error", err).Error("failed to open existing file on system")
return nil, sftp.ErrSSHFxFailure return nil, sftp.ErrSSHFxFailure
} }
// Chown may or may not have been called in the touch function, so always do
// it at this point to avoid the file being improperly owned.
_ = h.server.Filesystem().Chown(request.Filepath)
return f, nil return f, nil
} }