mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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:
committed by
Jan Cholasta
parent
8660b9e968
commit
d4aa75d105
@@ -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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user