From bc3906f9aacb5081d0e50365eb64f3848ef490d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Tue, 16 Feb 2021 06:45:09 +0200 Subject: [PATCH] ipa-replica-manage: handle missing attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If nsds5replicalastupdateend is not yet present, ipa-replica-manage will backtrace as it tries to retrieve that attribute unconditionally. Gracefully handle that situation. Fixes: https://pagure.io/freeipa/issue/8605 Signed-off-by: François Cami Reviewed-By: Rob Crittenden Reviewed-By: Florence Blanc-Renaud --- install/tools/ipa-replica-manage.in | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/install/tools/ipa-replica-manage.in b/install/tools/ipa-replica-manage.in index 1486ada42..2a77a404d 100644 --- a/install/tools/ipa-replica-manage.in +++ b/install/tools/ipa-replica-manage.in @@ -242,12 +242,18 @@ def list_replicas(realm, host, replica, dirman_passwd, verbose, nolookup=False): if initstatus is not None: print(" last init ended: %s" % str( ipautil.parse_generalized_time( - entry.single_value['nsds5replicalastinitend']))) - print(" last update status: %s" % entry.single_value.get( - 'nsds5replicalastupdatestatus')) - print(" last update ended: %s" % str( - ipautil.parse_generalized_time( - entry.single_value['nsds5replicalastupdateend']))) + entry.single_value['nsds5replicalastinitend'])) + ) + updatestatus = entry.single_value.get( + 'nsds5replicalastupdatestatus' + ) + print(" last update status: %s" % updatestatus) + if updatestatus is not None: + print(" last update ended: %s" % str( + ipautil.parse_generalized_time( + entry.single_value['nsds5replicalastupdateend'] + )) + ) def del_link(realm, replica1, replica2, dirman_passwd, force=False):