From 37fc5ea78f48ab32cb647da4265d55d569a6ba30 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 17 Feb 2023 16:21:08 +0100 Subject: [PATCH] entrypoint: don't consider chown failure critical as volumes may be mounted read-only. --- entrypoint/main.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/entrypoint/main.go b/entrypoint/main.go index a63e6f3..ada459c 100644 --- a/entrypoint/main.go +++ b/entrypoint/main.go @@ -44,16 +44,18 @@ func entrypoint() error { if os.Getuid() == 0 { 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 { - if err != nil { - return err + _ = filepath.WalkDir(dataVolume, func(path string, _ fs.DirEntry, err error) error { + if err == nil { + err = os.Lchown(path, wwwdataUid, wwwdataUid) } - return os.Lchown(path, wwwdataUid, wwwdataUid) + if err != nil { + logf("warn", "Can't chown %s: %s", path, err.Error()) + return filepath.SkipDir + } + + return nil }) - if err != nil { - return err - } logf("info", "Dropping privileges as we're root")