entrypoint: don't consider chown failure critical

as volumes may be mounted read-only.
This commit is contained in:
Alexander A. Klimov 2023-02-17 16:21:08 +01:00
parent 43b34b05d0
commit 37fc5ea78f

View File

@ -44,17 +44,19 @@ func entrypoint() error {
if os.Getuid() == 0 { if os.Getuid() == 0 {
logf("info", "Giving %s to the www-data user as we're root", dataVolume) logf("info", "Giving %s to the www-data user as we're root", dataVolume)
err := filepath.WalkDir(dataVolume, func(path string, _ fs.DirEntry, err error) error { _ = filepath.WalkDir(dataVolume, func(path string, _ fs.DirEntry, err error) error {
if err != nil { if err == nil {
return err err = os.Lchown(path, wwwdataUid, wwwdataUid)
} }
return os.Lchown(path, wwwdataUid, wwwdataUid)
})
if err != nil { if err != nil {
return err logf("warn", "Can't chown %s: %s", path, err.Error())
return filepath.SkipDir
} }
return nil
})
logf("info", "Dropping privileges as we're root") logf("info", "Dropping privileges as we're root")
if err := syscall.Setgid(wwwdataUid); err != nil { if err := syscall.Setgid(wwwdataUid); err != nil {