RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1357495 - ipa command provides stack trace when provided with single hypen commands
Summary: ipa command provides stack trace when provided with single hypen commands
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: ipa
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: IPA Maintainers
QA Contact: Kaleem
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-18 11:41 UTC by Abhijeet Kasurde
Modified: 2023-09-14 23:59 UTC (History)
10 users (show)

Fixed In Version: ipa-4.9.0-0.1.rc1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 15:47:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Abhijeet Kasurde 2016-07-18 11:41:24 UTC
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

Comment 2 Martin Bašti 2016-07-22 10:30:15 UTC
Upstream ticket:
https://fedorahosted.org/freeipa/ticket/6115

Comment 3 Petr Vobornik 2017-04-06 16:05:42 UTC
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.

Comment 5 Rob Crittenden 2018-05-11 17:15:43 UTC
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

Comment 8 Rob Crittenden 2020-08-24 22:44:35 UTC
Upstream PR https://github.com/freeipa/freeipa/pull/5063

Comment 19 Sumedh Sidhaye 2020-12-17 11:45:51 UTC
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%]

Comment 22 errata-xmlrpc 2021-05-18 15:47:45 UTC
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

Comment 23 Red Hat Bugzilla 2023-09-14 23:59:47 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 500 days


Note You need to log in before you can comment on or make changes to this bug.