From 5c97520906848a7f740d340ec0fe9c01f7306476 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 6 Apr 2022 12:05:20 -0400 Subject: [PATCH] Make IsSetID public so that Podman can use it Signed-off-by: Daniel J Walsh --- pkg/unshare/unshare_linux.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/unshare/unshare_linux.go b/pkg/unshare/unshare_linux.go index 2b968605c5..baeb8f1aab 100644 --- a/pkg/unshare/unshare_linux.go +++ b/pkg/unshare/unshare_linux.go @@ -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 @@ -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 { @@ -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 {