From eff0bb6caad5819f8893984c1264b5646f118408 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 22 Jun 2013 20:06:53 -0700 Subject: [PATCH] Add check for no valid keyid/longkeyid found in ldap data Account for missing gpgkey key Prevent a double error message --- gkeyldap/cli.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py index bf4e00e..03671b5 100644 --- a/gkeyldap/cli.py +++ b/gkeyldap/cli.py @@ -245,6 +245,8 @@ class Main(object): @staticmethod def build_gkeylist(info): keyinfo = [] + keyid_found = False + keyid_missing = False #logger.debug("MAIN: build_gkeylist; info = %s" % str(info)) for x in GKEY._fields: field = gkey2ldap_map[x] @@ -259,6 +261,8 @@ class Main(object): # separate out short/long key id's elif values and x in ['keyid', 'longkeyid']: value = get_key_ids(x, values) + if len(value): + keyid_found = True else: value = values if 'undefined' in values: @@ -268,6 +272,16 @@ class Main(object): except KeyError: logger.error("Missing %s (%s) for %s, %s" %(field, x, info['uid'][0], info['cn'][0])) + if x in ['keyid', 'longkeyid']: + keyid_missing = True keyinfo.append(None) + if not keyid_found and not keyid_missing: + try: + gpgkey = info[gkey2ldap_map['longkeyid']] + except KeyError: + gpgkey = 'Missing from ldap info' + logger.error("A valid keyid or longkeyid was not found for") + logger.error("developer: %s, %s : gpgkey = %s" + %(info['uid'][0], info['cn'][0], gpgkey)) return keyinfo -- 2.26.2