Skip to content

Commit

Permalink
Merge pull request #2249 from claudiubelu/fixes-missing-passwd-file
Browse files Browse the repository at this point in the history
Skips getting UID/GUID if passwd/group file is not found
  • Loading branch information
tonistiigi authored Jul 13, 2021
2 parents 06e8602 + 449d010 commit d3cd28f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions solver/llbsolver/file/user_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package file

import (
"os"
"syscall"

"github.com/containerd/continuity/fs"
"github.com/moby/buildkit/snapshot"
Expand Down Expand Up @@ -45,6 +46,10 @@ func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error)
}

ufile, err := os.Open(passwdPath)
if errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) {
// Couldn't open the file. Considering this case as not finding the user in the file.
break
}
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -95,6 +100,10 @@ func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error)
}

gfile, err := os.Open(groupPath)
if errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) {
// Couldn't open the file. Considering this case as not finding the group in the file.
break
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d3cd28f

Please sign in to comment.