Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IsSetID public so that Podman can use it #1192

Merged
merged 1 commit into from Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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