diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2015-04-20 10:43:45 -0700 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2015-05-30 16:25:13 -0700 |
commit | c87ffff6633693275ca5bbb67f81102bd2838123 (patch) | |
tree | 43aed717b913c48d9786282a693a56472559427d /gkeys-ldap | |
parent | gkeys/gkey.py: Fix typo in @license (diff) | |
download | gentoo-keys-c87ffff6633693275ca5bbb67f81102bd2838123.tar.gz gentoo-keys-c87ffff6633693275ca5bbb67f81102bd2838123.tar.bz2 gentoo-keys-c87ffff6633693275ca5bbb67f81102bd2838123.zip |
gkeys-ldap: Remove keyid/longkeyid from ldap search info
Diffstat (limited to 'gkeys-ldap')
-rw-r--r-- | gkeys-ldap/gkeyldap/actions.py | 42 | ||||
-rw-r--r-- | gkeys-ldap/gkeyldap/config.py | 5 |
2 files changed, 5 insertions, 42 deletions
diff --git a/gkeys-ldap/gkeyldap/actions.py b/gkeys-ldap/gkeyldap/actions.py index 9558ed0..9d7a231 100644 --- a/gkeys-ldap/gkeyldap/actions.py +++ b/gkeys-ldap/gkeyldap/actions.py @@ -142,7 +142,7 @@ class Actions(object): @staticmethod def get_args(args): - for attr in ['nick', 'name', 'gpgkey', 'fingerprint', 'status']: + for attr in ['nick', 'name', 'fingerprint', 'status']: if attr: target = getattr(args, attr) search_field = gkey2SEARCH[attr] @@ -162,7 +162,7 @@ class Actions(object): % (info['uid'][0], info['cn'][0])) self.logger.debug(' MISSING or EMPTY LDAP field ' + '[%s] GPGKey field [%s]' % (field, attr)) - if attr in ['fingerprint', 'keyid', 'longkeyid']: + if attr in ['fingerprint']: keyid_missing = True else: is_good = False @@ -172,15 +172,11 @@ class Actions(object): if is_good: if keyinfo['fingerprint']: # fingerprints exist check is_ok = self._check_fingerprint_integrity(info, keyinfo) - is_match = self._check_id_fingerprint_match(info, keyinfo) - if not is_ok or not is_match: + if not is_ok: is_good = False if is_good: # some developers add lowercase fingerprints keyinfo['fingerprint'] = [key.upper() for key in keyinfo['fingerprint']] - # drop keyid and longkeyid - keyinfo.pop('keyid', None) - keyinfo.pop('longkeyid', None) keyinfo['keys'] = keyinfo['fingerprint'] keyinfo['uid'] = ["%s <%s@gentoo.org>" % (info['cn'][0], info['uid'][0])] return keyinfo @@ -200,11 +196,7 @@ class Actions(object): values = info[field] # strip errant line feeds values = [y.strip('\n') for y in values] - # separate out short/long key id's - if values and attr in ['keyid', 'longkeyid']: - if len(get_key_ids(attr, values)): - keyid_found = True - elif values and attr in ['fingerprint']: + if values and attr in ['fingerprint']: values = [v.replace(' ', '') for v in values] if 'undefined' in values and attr not in ['keyid', 'longkeyid']: self.logger.error('ERROR in LDAP info for: %s, %s' @@ -242,35 +234,9 @@ class Actions(object): else: gpgkey = 'Missing or Bad fingerprint from LDAP info' is_good = False - #if not keyinfo['longkeyid']: - #self.logger.error('ERROR in ldap info for: %s, %s' - #% (info['uid'][0], info['cn'][0])) - #self.logger.error(' A valid keyid, longkeyid or fingerprint ' - #'was not found for %s : gpgkey = %s' % (info['cn'][0], gpgkey)) - #is_good = False return (keyinfo, is_good) - def _check_id_fingerprint_match(self, info, keyinfo): - # assume it's good until found an error is found - is_good = True - for attr in ['keyid', 'longkeyid']: - # skip blank id field - if not keyinfo[attr]: - continue - for y in keyinfo[attr]: - index = len(y.lstrip('0x')) - if y.lstrip('0x').upper() not in \ - [x[-index:].upper() for x in keyinfo['fingerprint']]: - self.logger.error('ERROR in LDAP info for: %s, %s' - %(info['uid'][0], info['cn'][0])) - self.logger.error(' ' + str(keyinfo)) - self.logger.error(' GPGKey id %s not found in the ' - % y.lstrip('0x') + 'listed fingerprint(s)') - is_good = False - return is_good - - def _check_fingerprint_integrity(self, info, keyinfo): # assume it's good until found an error is found is_good = True diff --git a/gkeys-ldap/gkeyldap/config.py b/gkeys-ldap/gkeyldap/config.py index f7fb837..fe56e78 100644 --- a/gkeys-ldap/gkeyldap/config.py +++ b/gkeys-ldap/gkeyldap/config.py @@ -5,15 +5,13 @@ default_server = ['ldap://ldap%d.gentoo.org' % i for i in xrange(1,5)] # add uid to the results so you don't have to # separate it out of the results tuple[0] value -default_fields = ['uid', 'cn', 'mail', 'gentooStatus', 'gpgkey', 'gpgfingerprint'] +default_fields = ['uid', 'cn', 'mail', 'gentooStatus', 'gpgfingerprint'] default_criteria = 'ou=devs,dc=gentoo,dc=org' # establish a ldap fields to GKEY._fields map gkey2ldap = { 'nick': 'uid', 'name': 'cn', - 'keyid': 'gpgkey', - 'longkeyid': 'gpgkey', # map the uid to keydir, since we want # dev keydir to be separate from each other 'keydir': 'uid', @@ -33,7 +31,6 @@ gkey2SEARCH = { 'nick': UID, 'name': CN, 'status': STATUS, - 'keyid': GPGKEY, 'mail': MAIL, 'fingerprint': GPGFINGERPRINT, } |