Skip to content

Commit

Permalink
Merge pull request #1192 from rhatdan/setuid
Browse files Browse the repository at this point in the history
Make IsSetID public so that Podman can use it
  • Loading branch information
flouthoc committed Apr 6, 2022
2 parents 296e6aa + 5c97520 commit 4fb40a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/unshare/unshare_linux.go
Expand Up @@ -77,7 +77,9 @@ func getRootlessGID() int {
return os.Getegid()
}

func isSetID(path string, modeid os.FileMode, capid capability.Cap) (bool, error) {
// IsSetID checks if specified path has correct FileMode (Setuid|SETGID) or the
// matching file capabilitiy
func IsSetID(path string, modeid os.FileMode, capid capability.Cap) (bool, error) {
info, err := os.Stat(path)
if err != nil {
return false, err
Expand Down Expand Up @@ -248,7 +250,7 @@ func (c *Cmd) Start() error {
gidmapSet = true
} else {
logrus.Warnf("Error running newgidmap: %v: %s", err, g.String())
isSetgid, err := isSetID(path, os.ModeSetgid, capability.CAP_SETGID)
isSetgid, err := IsSetID(path, os.ModeSetgid, capability.CAP_SETGID)
if err != nil {
logrus.Warnf("Failed to check for setgid on %s: %v", path, err)
} else {
Expand Down Expand Up @@ -308,7 +310,7 @@ func (c *Cmd) Start() error {
uidmapSet = true
} else {
logrus.Warnf("Error running newuidmap: %v: %s", err, u.String())
isSetuid, err := isSetID(path, os.ModeSetuid, capability.CAP_SETUID)
isSetuid, err := IsSetID(path, os.ModeSetuid, capability.CAP_SETUID)
if err != nil {
logrus.Warnf("Failed to check for setuid on %s: %v", path, err)
} else {
Expand Down

0 comments on commit 4fb40a4

Please sign in to comment.