Merge pull request #14 from matthewpi/chown-fix

Chown directories, not just files.  Fixes #1814
This commit is contained in:
Dane Everitt 2020-02-08 13:29:55 -08:00 committed by GitHub
commit 679e21a6dd

View File

@ -87,7 +87,7 @@ func (fs *Filesystem) SafePath(p string) (string, error) {
return "", InvalidPathResolution return "", InvalidPathResolution
} }
// If the nonExistentPathResoltion variable is not empty then the initial path requested // If the nonExistentPathResolution variable is not empty then the initial path requested
// did not exist and we looped through the pathway until we found a match. At this point // did not exist and we looped through the pathway until we found a match. At this point
// we've confirmed the first matched pathway exists in the root server directory, so we // we've confirmed the first matched pathway exists in the root server directory, so we
// can go ahead and just return the path that was requested initially. // can go ahead and just return the path that was requested initially.
@ -373,6 +373,9 @@ func (fs *Filesystem) chownDirectory(path string) error {
return errors.WithStack(err) return errors.WithStack(err)
} }
// Chown the directory itself.
os.Chown(cleaned, config.Get().System.User.Uid, config.Get().System.User.Gid)
files, err := ioutil.ReadDir(cleaned) files, err := ioutil.ReadDir(cleaned)
if err != nil { if err != nil {
return errors.WithStack(err) return errors.WithStack(err)
@ -387,6 +390,7 @@ func (fs *Filesystem) chownDirectory(path string) error {
fs.chownDirectory(p) fs.chownDirectory(p)
}(filepath.Join(cleaned, f.Name())) }(filepath.Join(cleaned, f.Name()))
} else { } else {
// Chown the file.
os.Chown(filepath.Join(cleaned, f.Name()), fs.Configuration.User.Uid, fs.Configuration.User.Gid) os.Chown(filepath.Join(cleaned, f.Name()), fs.Configuration.User.Uid, fs.Configuration.User.Gid)
} }
} }
@ -567,4 +571,4 @@ func (fs *Filesystem) EnsureDataDirectory() error {
} }
return nil return nil
} }