Bug 2174297
Summary: | Environment module does not accept values with white-space when registering system in interactive mode | |||
---|---|---|---|---|
Product: | Red Hat Enterprise Linux 9 | Reporter: | Archana Pandey <arpandey> | |
Component: | subscription-manager | Assignee: | Pino Toscano <ptoscano> | |
Status: | CLOSED ERRATA | QA Contact: | Red Hat subscription-manager QE Team <rhsm-qe> | |
Severity: | high | Docs Contact: | ||
Priority: | medium | |||
Version: | 9.2 | CC: | jsefler, jstavel, ptoscano, redakkan | |
Target Milestone: | rc | Keywords: | Triaged | |
Target Release: | 9.3 | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | subscription-manager-1.29.34-1.el9 | Doc Type: | No Doc Update | |
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 2174887 (view as bug list) | Environment: | ||
Last Closed: | 2023-11-07 08:51:53 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 2174887 |
Description
Archana Pandey
2023-03-01 03:58:05 UTC
(In reply to Archana Pandey from comment #0) > [root@kvm-03-guest14 ~]# subscription-manager register --username testuser1 > --password ***** --org ******* > Registering to: archana-candlepin.usersys.redhat.com:8443/candlepin > Hint: Organization "******" contains following environments: DevEnv, Test > Env1 > Environments: Test Env1 > No such environment: TestEnv1 <<<< it simply removes the space from value > provided Typing the environments like this (environment names as-they-are) is correct. > [root@kvm-03-guest14 ~]# subscription-manager register --username testuser1 > --password ****** --org **** > Registering to: archana-candlepin.usersys.redhat.com:8443/candlepin > Hint: Organization "*******" contains following environments: DevEnv, Test > Env1 > Environments: "Test\ Env1" > No such environment: "Test\Env1" <<<< it simply removes the space from > value provided This is not correct, as there is no unquoting or unescaping done. The problem happens only when asking the user for environments: https://github.com/candlepin/subscription-manager/blob/82a44c368f4f83c32d1933b774d731a5c341e9ef/src/subscription_manager/cli_command/register.py#L441-L444 Tracking back the history of this code, we have (ignoring no-op commits): - https://github.com/candlepin/subscription-manager/commit/7d0199fb9419daad10530ad87cb2ef7fdae37a62 this re-adds support for non-multi-environments scenarios - https://github.com/candlepin/subscription-manager/commit/19ae947ad78a517d8ba999fdc41b62dcd850dbad this adds support for multiple environments: note that the `strip()` for non-multi-environments (i.e. only trailing and leading whitespace characters are removed) becomes `replace(" ", "")` (i.e. every single space is removed) (both the commit above are part of https://github.com/candlepin/subscription-manager/pull/2920 ) - https://github.com/candlepin/subscription-manager/commit/69c4921f4fd9915e19317af44c4bf72cc5bf72e1 (part of https://github.com/candlepin/subscription-manager/pull/989 ) this is introduces the interactive query for an environment, doing the `strip()` in the input (unlike what other `input()` prompts do) My notes: - I'm not sure why the input is `strip()`ed for non-multi-environment input; the original commit doesn't say that - I think the logic in removing spaces in the multi-environment case was done to mimic the non-multi-environment one, sadly in a sub-optimal way which creates this issue The user may type any arbitrary amount of environments to register to when prompted interactively, so I think that the logic to strip spaces is most likely still needed: an input string "Env 1, Env2,MyEnv" must result in "Env 1", "Env2", "MyEnv" (and not as "Env 1", " Env2", "MyEnv"). Looking at the code: - the result of `RegisterCommand._prompt_for_environment()` is passed directly to `check_set_environment_names()` - `check_set_environment_names()` does `strip()` on the split elements of an environment string: https://github.com/candlepin/subscription-manager/blob/82a44c368f4f83c32d1933b774d731a5c341e9ef/src/subscription_manager/cli_command/environments.py#L196-L203 Hence, I think we can safely do a single `strip()` on the input of `RegisterCommand._prompt_for_environment()`, in both multi-environments and non-multi-environments scenarios: this way, empty or whitespace-only inputs are rejected, prompting the user again. Attempt of PR for this: https://github.com/candlepin/subscription-manager/pull/3219 added a playbook to simulate this case. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (subscription-manager bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:6606 |