ipapwpolicy: simplified and faster attribute verification

Use a simpler and faster 'any()' test instead of creating two lists and
checking if resulting list is empty.
This commit is contained in:
Rafael Guterres Jeffman
2023-04-11 18:45:49 -03:00
parent cf27a98c61
commit a69446021b

View File

@@ -230,17 +230,15 @@ def check_supported_params(
"pwpolicy_add", "passwordgracelimit") "pwpolicy_add", "passwordgracelimit")
# If needed, report unsupported password checking paramteres # If needed, report unsupported password checking paramteres
if not has_password_check: if (
check_password_params = [maxrepeat, maxsequence, dictcheck, usercheck] not has_password_check
unsupported = [ and any([maxrepeat, maxsequence, dictcheck, usercheck])
x for x in check_password_params if x is not None ):
] module.fail_json(
if unsupported: msg="Your IPA version does not support arguments: "
module.fail_json( "maxrepeat, maxsequence, dictcheck, usercheck.")
msg="Your IPA version does not support arguments: "
"maxrepeat, maxsequence, dictcheck, usercheck.")
if gracelimit is not None and not has_gracelimit: if not has_gracelimit and gracelimit is not None:
module.fail_json( module.fail_json(
msg="Your IPA version does not support 'gracelimit'.") msg="Your IPA version does not support 'gracelimit'.")