diff --git a/pkg/idtools/idtools_unix.go b/pkg/idtools/idtools_unix.go index 2a2fb73bb8..5ecd2619bc 100644 --- a/pkg/idtools/idtools_unix.go +++ b/pkg/idtools/idtools_unix.go @@ -90,20 +90,17 @@ func CanAccess(path string, pair Identity) bool { if err != nil { return false } - fileMode := os.FileMode(statInfo.Mode()) - permBits := fileMode.Perm() - return accessible(statInfo.UID() == uint32(pair.UID), - statInfo.GID() == uint32(pair.GID), permBits) -} - -func accessible(isOwner, isGroup bool, perms os.FileMode) bool { - if isOwner && (perms&0100 == 0100) { + perms := os.FileMode(statInfo.Mode()).Perm() + if perms&0o001 == 0o001 { + // world access return true } - if isGroup && (perms&0010 == 0010) { + if statInfo.UID() == uint32(pair.UID) && (perms&0o100 == 0o100) { + // owner access. return true } - if perms&0001 == 0001 { + if statInfo.GID() == uint32(pair.GID) && (perms&0o010 == 0o010) { + // group access. return true } return false