Skip to content

Commit

Permalink
cmd/root: Don't validate subordinate IDs when generating the completions
Browse files Browse the repository at this point in the history
Ever since commit bafbbe8, 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 don't have subordinate ID ranges
set up.  Therefore, it's better to avoid validating them when generating
the shell completions, especially, 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.

containers#1246
  • Loading branch information
JanZerebecki authored and debarshiray committed Mar 1, 2023
1 parent c852304 commit 6a0233c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6a0233c

Please sign in to comment.