Skip to content

Commit

Permalink
rootless: fix open /etc/docker/plugins: permission denied
Browse files Browse the repository at this point in the history
Fix issue 47436

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit d742659)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
AkihiroSuda authored and vvoland committed Mar 19, 2024
1 parent 5901652 commit 81ad706
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/plugins/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"strings"
"sync"

"github.com/containerd/containerd/pkg/userns"
"github.com/containerd/log"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -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()))
Expand Down

0 comments on commit 81ad706

Please sign in to comment.