py3: ipa_generate_password: do not compare None and Int

The one cannot compare None and Int in Py3
"""
unorderable types: NoneType() > int()
"""

Continue when class is disabled with None value

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti 2017-02-07 19:24:46 +01:00 committed by Jan Cholasta
parent 69072cb80f
commit dd119f8aad

View File

@ -860,6 +860,8 @@ def ipa_generate_password(entropy_bits=256, uppercase=1, lowercase=1, digits=1,
for charclass_name in ['digits', 'uppercase', 'lowercase', 'special']:
charclass = pwd_charsets[charclass_name]
todo_characters = req_classes[charclass_name]
if todo_characters is None:
continue
while todo_characters > 0:
password += rnd.choice(charclass['chars'])
todo_entropy -= charclass['entropy']