python:gp: Do not print an error, if CA already exists
authorAndreas Schneider <asn@samba.org>
Mon, 22 Jan 2024 14:04:36 +0000 (15:04 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 29 Jan 2024 09:32:46 +0000 (09:32 +0000)
We will get an exit status for duplicate in future:
https://www.pagure.io/certmonger/issue/269
We can't really fix that right now, as older version of certmonger
don't support the `-v` option.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15559

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
python/samba/gp/gp_cert_auto_enroll_ext.py

index e07f4276b845f23eaff42f129e137cd7e52aee57..1547e9db98336e04590e6ee933cb231ae38d89ea 100644 (file)
@@ -318,8 +318,12 @@ def cert_enroll(ca, ldb, trust_dir, private_dir, auth='Kerberos'):
         out, err = p.communicate()
         log.debug(out.decode())
         if p.returncode != 0:
-            data = { 'Error': err.decode(), 'CA': ca['name'] }
-            log.error('Failed to add Certificate Authority', data)
+            if p.returncode == 2:
+                log.info('The CA [%s] already exists' % ca['name'])
+            else:
+                data = {'Error': err.decode(), 'CA': ca['name']}
+                log.error('Failed to add Certificate Authority', data)
+
         supported_templates = get_supported_templates(ca['hostname'])
         for template in supported_templates:
             attrs = fetch_template_attrs(ldb, template)