From d742659877d9bf0bfe64b97e529bc28667974607 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 14 Mar 2024 14:32:01 +0900 Subject: [PATCH] rootless: fix `open /etc/docker/plugins: permission denied` Fix issue 47436 Signed-off-by: Akihiro Suda --- pkg/plugins/discovery.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/plugins/discovery.go b/pkg/plugins/discovery.go index 37316ed482..503ac574a9 100644 --- a/pkg/plugins/discovery.go +++ b/pkg/plugins/discovery.go @@ -10,6 +10,8 @@ import ( "strings" "sync" + "github.com/containerd/containerd/pkg/userns" + "github.com/containerd/log" "github.com/pkg/errors" ) @@ -56,10 +58,16 @@ func (l *LocalRegistry) Scan() ([]string, error) { for _, p := range l.specsPaths { dirEntries, err = os.ReadDir(p) - if err != nil && !os.IsNotExist(err) { + if err != nil { + if os.IsNotExist(err) { + continue + } + if os.IsPermission(err) && userns.RunningInUserNS() { + log.L.Debug(err.Error()) + continue + } return nil, errors.Wrap(err, "error reading dir entries") } - for _, entry := range dirEntries { if entry.IsDir() { infos, err := os.ReadDir(filepath.Join(p, entry.Name()))