idrange-add: properly handle empty --dom-name option

When idrange-add is called with --dom-name=, the CLI exits with
ipa: ERROR: an internal error has occurred
This happens because the code checks if the option is provided but does not
check if the value is None.

We need to handle empty dom-name as if the option was not specified.

https://pagure.io/freeipa/issue/6404

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2017-03-28 16:02:45 +02:00 committed by Tomas Krizek
parent 1aa77fe389
commit 70743c8c48
No known key found for this signature in database
GPG Key ID: 22A2A94B5E49415A

View File

@ -411,7 +411,7 @@ class idrange_add(LDAPCreate):
# This needs to stay in options since there is no
# ipanttrusteddomainname attribute in LDAP
if 'ipanttrusteddomainname' in options:
if options.get('ipanttrusteddomainname'):
if is_set('ipanttrusteddomainsid'):
raise errors.ValidationError(name='ID Range setup',
error=_('Options dom-sid and dom-name '