From 301788805c069788344f9c8d4feb5afea398d8a0 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 23 Jan 2022 13:14:02 -0500 Subject: [PATCH] Ensure a file uploaded using SFTP is properly owned at the end; closes pterodactyl/panel#3689 --- sftp/handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sftp/handler.go b/sftp/handler.go index aeba53c..2bbd729 100644 --- a/sftp/handler.go +++ b/sftp/handler.go @@ -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") 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 }