Bug 1357495
| Summary: | ipa command provides stack trace when provided with single hypen commands | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Abhijeet Kasurde <akasurde> |
| Component: | ipa | Assignee: | IPA Maintainers <ipa-maint> |
| Status: | CLOSED ERRATA | QA Contact: | Kaleem <ksiddiqu> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 8.0 | CC: | abokovoy, ipa-maint, mpolovka, ndehadra, pasik, pvoborni, rcritten, ssidhaye, tscherf, twoerner |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | ipa-4.9.0-0.1.rc1 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-05-18 15:47:45 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: | |||
Upstream ticket: https://fedorahosted.org/freeipa/ticket/6115 IdM team doesn't have capacity to fix this bug for RHEL 7.4. Moving to next RHEL version. Fixing the bug there will depend on capacity of FreeIPA upstream. Without sufficient justification there is a chance that it will be moved again later. Single options are fine. The problem in this case is different.
# ipa -verbose
This is option -v, option -e and rbose as an environment variable without an = sign which is invalid.
# ipa -ver
Virtually the same, just with r as the environment.
# ipa -e aa
Same, aa as an environment variable and no value.
I think the log failure is masking the actual error.
We see a different error in master:
UnboundLocalError: local variable 'value' referenced before assignment
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/ipalib/cli.py", line 1403, in run
(_options, argv) = api.bootstrap_with_global_options(context='cli')
File "/usr/lib/python3.6/site-packages/ipalib/plugable.py", line 594, in bootstrap_with_global_options
overrides[str(key.strip())] = value.strip()
UnboundLocalError: local variable 'value' referenced before assignment
an internal error has occurred
value is unreferenced because it is obtained via:
(key, value) = item.split('=', 1)
Since there is no = there is no value so it blows up.
I think this will fix it:
--- ipalib/plugable.py
@@ -585,13 +585,18 @@
assert type(options.env) is list
for item in options.env:
try:
- (key, value) = item.split('=', 1)
+ values = item.split('=', 1)
except ValueError:
# FIXME: this should raise an IPA exception with an
# error code.
# --Jason, 2008-10-31
pass
- overrides[str(key.strip())] = value.strip()
+ if len(values) == 2:
+ (key, value) = values
+ overrides[str(key.strip())] = value.strip()
+ else:
+ raise errors.OptionError(_('Unable to parse option {item}'
+ .format(item=item)))
for key in ('conf', 'debug', 'verbose', 'prompt_all', 'interactive',
'fallback', 'delegate'):
value = getattr(options, key, None)
The only problem with the exception is that it isn't clear what is actually wrong. For example for the case of -verbose the error is:
Unable to parse option rbose
Upstream PR https://github.com/freeipa/freeipa/pull/5063 Fixed upstream master: https://pagure.io/freeipa/c/4a89da5352314cad4417ee42eac2cd8ad7cdc057 https://pagure.io/freeipa/c/12dfb0fc96ad6db3aa2cd5a56b6cbc8cd092751a ipa-4-8: https://pagure.io/freeipa/c/6f4f7c616628a6200f7d3b56969d6e6204d3aea5 https://pagure.io/freeipa/c/dce5b1c854382058c62cb7c7155edf715088ca0a Builds used for verification: ipa-client-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.x86_64 ipa-client-common-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.noarch ipa-common-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.noarch ipa-healthcheck-core-0.7-3.module+el8.4.0+9007+5084bdd8.noarch ipa-selinux-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.noarch ipa-server-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.x86_64 ipa-server-common-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.noarch ipa-server-dns-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.noarch ipa-server-trust-ad-4.9.0-0.5.rc3.module+el8.4.0+9124+ced20601.x86_64 test_ipalib/test_plugable.py::test_cli::test_no_args PASSED [ 25%] test_ipalib/test_plugable.py::test_cli::test_one_arg PASSED [ 50%] test_ipalib/test_plugable.py::test_cli::test_args_valid_option PASSED [ 75%] test_ipalib/test_plugable.py::test_cli::test_args_invalid_option PASSED [100%] 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 (Moderate: idm:DL1 and idm:client security, 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/RHSA-2021:1846 The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days |
Description of problem: If user provides commands such as following, then ipa command provides stack trace instead of error message to user. # ipa -verbose Traceback (most recent call last): File "/usr/bin/ipa", line 32, in <module> cli.run(api) File "/usr/lib/python2.7/site-packages/ipalib/cli.py", line 1346, in run api.log.exception('%s: %s', e.__class__.__name__, str(e)) AttributeError: 'API' object has no attribute 'log' # ipa -ver Traceback (most recent call last): File "/usr/bin/ipa", line 32, in <module> cli.run(api) File "/usr/lib/python2.7/site-packages/ipalib/cli.py", line 1346, in run api.log.exception('%s: %s', e.__class__.__name__, str(e)) AttributeError: 'API' object has no attribute 'log' # ipa -e aa Traceback (most recent call last): File "/usr/bin/ipa", line 32, in <module> cli.run(api) File "/usr/lib/python2.7/site-packages/ipalib/cli.py", line 1346, in run api.log.exception('%s: %s', e.__class__.__name__, str(e)) AttributeError: 'API' object has no attribute 'log' Version-Release number of selected component (if applicable): ipa-server-4.2.0-15.el7_2.17.x86_64 How reproducible: 100% Steps to Reproduce: 1. ipa -verbose # or 2. ipa -e aa # or 3. ipa -ver Actual results: IPA command provides stack traces Expected results: IPA command should provide user friendly information about unknown command