Bug 816574

Summary: ipa permission-add throws internal server error when --addattr or --setattr is blank
Product: Red Hat Enterprise Linux 6 Reporter: Namita Soman <nsoman>
Component: ipaAssignee: Rob Crittenden <rcritten>
Status: CLOSED ERRATA QA Contact: Namita Soman <nsoman>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.2CC: jgalipea, mkosek
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ipa-3.0.0-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 09:11: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:

Description Namita Soman 2012-04-26 12:40:02 UTC
Description of problem:
ipa permission-add throws internal server error when --addattr or --setattr is blank
# ipa permission-add TestPermission --permissions="write" --type=hostgroup --attr=carlicense --addattr=
And
# ipa permission-add TestPermission --permissions="write" --type=hostgroup --attr=carlicense --setattr=""

throw 
ipa: ERROR: an internal error has occurred

Version-Release number of selected component (if applicable):
ipa-server-2.2.0-11.el6.x86_64


How reproducible:
always

Steps to Reproduce:
1.# ipa permission-add TestPermission --permissions="write" --type=hostgroup --attr=carlicense --addattr=

  
Actual results:
ipa: ERROR: an internal error has occurred


Expected results:
Better error

Additional info:
[Thu Apr 26 08:27:15 2012] [error] ipa: INFO: admin: privilege_add(u'Add User with blank attr', description=u'Add User with blank attr', setattr=None, all=False, raw=False, version=u'2.34'): TypeError
[Thu Apr 26 08:32:08 2012] [error] ipa: ERROR: non-public: TypeError: expected string or buffer
[Thu Apr 26 08:32:08 2012] [error] Traceback (most recent call last):
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipaserver/rpcserver.py", line 320, in wsgi_execute
[Thu Apr 26 08:32:08 2012] [error]     result = self.Command[name](*args, **options)
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipalib/frontend.py", line 438, in __call__
[Thu Apr 26 08:32:08 2012] [error]     ret = self.run(*args, **options)
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipalib/frontend.py", line 716, in run
[Thu Apr 26 08:32:08 2012] [error]     return self.execute(*args, **options)
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipalib/plugins/baseldap.py", line 978, in execute
[Thu Apr 26 08:32:08 2012] [error]     self.process_attr_options(entry_attrs, None, keys, options)
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipalib/plugins/baseldap.py", line 853, in process_attr_options
[Thu Apr 26 08:32:08 2012] [error]     adddict = self._convert_2_dict(options.get('addattr', []))
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib/python2.6/site-packages/ipalib/plugins/baseldap.py", line 806, in _convert_2_dict
[Thu Apr 26 08:32:08 2012] [error]     m = re.match("\\s*(.*?)\\s*=\\s*(.*?)\\s*$", a)
[Thu Apr 26 08:32:08 2012] [error]   File "/usr/lib64/python2.6/re.py", line 137, in match
[Thu Apr 26 08:32:08 2012] [error]     return _compile(pattern, flags).match(string)
[Thu Apr 26 08:32:08 2012] [error] TypeError: expected string or buffer
[Thu Apr 26 08:32:08 2012] [error] ipa: INFO: admin: permission_add(u'TestPermission', permissions=(u'write',), attrs=(u'carlicense',), type=u'hostgroup', addattr=None, all=False, raw=False, version=u'2.34'): TypeError

Comment 2 Martin Kosek 2012-04-26 13:06:26 UTC
Upstream ticket:
https://fedorahosted.org/freeipa/ticket/2680

Comment 3 Martin Kosek 2012-05-07 15:24:22 UTC
Fixed upstream:
master: https://fedorahosted.org/freeipa/changeset/abef5e8c027bf37d9522f4d30e8e43c408251893

Comment 6 Namita Soman 2013-01-14 14:25:14 UTC
Verified using: ipa-server-3.0.0-20.el6.x86_64

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: ipa-permission-cli-1032 - add permission with missing addattr value (bug 816574)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Verify error message for missing addattr
:: [   PASS   ] :: File '/tmp/tmp.FGH5wfGkhd/ipapermission_missingaddattr1.log' should contain 'ipa: error: --addattr option requires an argument'

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: ipa-permission-cli-1034 - add permission with missing setattr value (bug 816574)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Verify error message for missing setattr
:: [   PASS   ] :: File '/tmp/tmp.nqBo9qpHMv/ipapermission_missingsetattr1.log' should contain 'ipa: error: --setattr option requires an argument'

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: ipa-privilege-cli-1010 - add privilege with blank setattr (bug 816574)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Verify Add User with blank attr privilege is added successfully
:: [   PASS   ] :: File '/tmp/tmp.nqBo9qpHMv/ipaprivilege_blankattr.log' should contain 'Added privilege "Add User with blank attr"'


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: ipa-role-cli-1009 - add role with blank setattr (bug 816574)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Running 'addRole "Hostgroup Admin with blank seeAlso" "Hostgroup Admin with blank seeAlso" --setattr="" > /tmp/tmp.nqBo9qpHMv/iparole_blankattr.log 2>&1'
:: [   PASS   ] :: File '/tmp/tmp.nqBo9qpHMv/iparole_blankattr.log' should contain 'Added role "Hostgroup Admin with blank seeAlso"'

Comment 8 errata-xmlrpc 2013-02-21 09:11:53 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, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0528.html