custodia: kem.set_keys: replace too-broad exception

Exception is too brod and may hide various issues that show up later. If
the code expects that entry may exist, then ldap.ALREADY_EXISTS
exception should be used

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti
2017-01-31 18:14:33 +01:00
committed by Jan Cholasta
parent 8660b9e968
commit d4aa75d105

View File

@@ -139,8 +139,7 @@ class KEMLdap(iSecLdap):
('memberPrincipal', principal.encode('utf-8')), ('memberPrincipal', principal.encode('utf-8')),
('ipaPublicKey', public_key)] ('ipaPublicKey', public_key)]
conn.add_s(dn, mods) conn.add_s(dn, mods)
except Exception: # pylint: disable=broad-except except ldap.ALREADY_EXISTS:
# This may fail if the entry already exists
mods = [(ldap.MOD_REPLACE, 'ipaPublicKey', public_key)] mods = [(ldap.MOD_REPLACE, 'ipaPublicKey', public_key)]
conn.modify_s(dn, mods) conn.modify_s(dn, mods)