MCPcopy
hub / github.com/containers/toolbox / validateSubIDRanges

Function validateSubIDRanges

src/cmd/root.go:408–432  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string, user *user.User)

Source from the content-addressed store, hash-verified

406}
407
408func validateSubIDRanges(cmd *cobra.Command, args []string, user *user.User) (bool, error) {
409 logrus.Debugf("Looking up sub-GID and sub-UID ranges for user %s", user.Username)
410
411 if user.Uid == "0" {
412 logrus.Debugf("Look-up not needed: user %s doesn't need them", user.Username)
413 return true, nil
414 }
415
416 if utils.IsInsideContainer() {
417 logrus.Debug("Look-up not needed: running inside a container")
418 return true, nil
419 }
420
421 if cmdName, completionCmdName := cmd.Name(), completionCmd.Name(); cmdName == completionCmdName {
422 logrus.Debugf("Look-up not needed: command %s doesn't need them", cmdName)
423 return true, nil
424 }
425
426 if _, err := utils.ValidateSubIDRanges(user); err != nil {
427 logrus.Debugf("Looking up sub-GID and sub-UID ranges failed: %s", err)
428 return false, newSubIDError()
429 }
430
431 return true, nil
432}

Callers 1

preRunFunction · 0.85

Calls 2

newSubIDErrorFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…