cmd/root: Don't validate subordinate IDs when generating the completions
Ever since commit bafbbe81c9
, the shell completions are generated
while building Toolbx using the 'completion' command. This involves
running toolbox(1) itself, and hence validating the subordinate user and
group ID ranges.
Unfortunately, some build environments, like openSUSE's, don't have
subordinate ID ranges set up. Therefore, it's better to not validate
the subordinate ID ranges when generating the shell completions, since
they are generated by Cobra itself and subordinate ID ranges are not
involved at all.
Note that subordinate ID ranges may be needed when the generated shell
completions are actually used in interactive command line environments.
The shell completions invoke the hidden '__complete' command to get the
results that are presented to the user, and, if needed, the subordinate
ID ranges will continue to be used by podman(1) as part of that.
Some changes by Debarshi Ray.
https://github.com/containers/toolbox/issues/1246
https://github.com/containers/toolbox/pull/1249
This commit is contained in:
parent
816a7cab9e
commit
f555029304
1 changed files with 5 additions and 0 deletions
|
@ -401,6 +401,11 @@ func validateSubIDRanges(cmd *cobra.Command, args []string, user *user.User) (bo
|
|||
return true, nil
|
||||
}
|
||||
|
||||
if cmdName, completionCmdName := cmd.Name(), completionCmd.Name(); cmdName == completionCmdName {
|
||||
logrus.Debugf("Look-up not needed: command %s doesn't need them", cmdName)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if _, err := utils.ValidateSubIDRanges(user); err != nil {
|
||||
logrus.Debugf("Looking for sub-GID and sub-UID ranges: %s", err)
|
||||
return false, newSubIDError()
|
||||
|
|
Loading…
Reference in a new issue