Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.

Fix issue whereby files are failed to be chown'ed due to not existing #2

Closed
wants to merge 1 commit into from

Conversation

rxdn
Copy link

@rxdn rxdn commented Nov 11, 2018

This PR is to rectify the following issue: pterodactyl/panel#1380

The logs provided by CodeCo state that on line 230, chown'ing the file fails because it doesn't exist. This appears to be because the chown is run even if the file was removed. I've added code that prevents the chown from running in the case of a file or directory removal.

@@ -249,8 +254,10 @@ func (fs FileSystem) Filecmd(request *sftp.Request) error {

// Not failing here is intentional. We still made the file, it is just owned incorrectly
// and will likely cause some issues.
if err := os.Chown(fileLocation, fs.User.Uid, fs.User.Gid); err != nil {
logger.Get().Warnw("error chowning file", zap.String("file", fileLocation), zap.Error(err))
if !isRemoval { // We can't perform a chown on a file that has been removed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just check if the request.Method is Rmdir or Remove?

@DaneEveritt
Copy link
Member

Closed in favor of #3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants