(cmd *cobra.Command, args []string, user *user.User)
| 406 | } |
| 407 | |
| 408 | func 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 | } |
no test coverage detected
searching dependent graphs…