From f555029304415a06bde410deb879cd2cc7dad444 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Wed, 1 Mar 2023 19:52:28 +0100 Subject: [PATCH] cmd/root: Don't validate subordinate IDs when generating the completions Ever since commit bafbbe81c9220cb3, 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 --- src/cmd/root.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/root.go b/src/cmd/root.go index 9aafe3e..aee9fe0 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -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()