aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2014-12-27 13:56:14 -0800
committerBrian Dolbec <dolsen@gentoo.org>2014-12-30 13:42:26 -0800
commit1626d81d20474cb55620bf19aa12924b28a795e9 (patch)
tree7c1a25ee4358b9aafeb84f15e02bab2f14ccb11f /gkeys/gkeys
parentgkeys: Add keys and uid options to actions and seed handling (diff)
downloadgentoo-keys-1626d81d20474cb55620bf19aa12924b28a795e9.tar.gz
gentoo-keys-1626d81d20474cb55620bf19aa12924b28a795e9.tar.bz2
gentoo-keys-1626d81d20474cb55620bf19aa12924b28a795e9.zip
gkeys/lib.py: Add the new GKEY.update() to add_key and refresh_key
This updates our installed gkey.seed with all fingerprints including sub-keys and uid's. This way searches for keys used to sign files can be found if the key used to sign the file was not a primary key.
Diffstat (limited to 'gkeys/gkeys')
-rw-r--r--gkeys/gkeys/lib.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 67c94ae..f8e6615 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -158,9 +158,8 @@ class GkeysGPG(GPG):
message += "\n gkey..: %s" % (str(gkey.fingerprint))
logger.error(message)
# Save the gkey seed to the installed db
- self.seedfile.update(gkey)
- if not self.seedfile.save():
- logger.error("GkeysGPG.add_key(); failed to save seed: " + gkey.nick)
+ success = self.update_gkey(gkey, save=True)
+ if not success:
return []
results.append(result)
return results
@@ -190,21 +189,32 @@ class GkeysGPG(GPG):
self.set_keyserver()
self.set_keydir(gkey.keydir, 'refresh-keys', reset=True)
self.set_keyring('pubring.gpg', 'refresh-keys', reset=False)
+ self.set_keyseedfile()
logger.debug("LIB: refresh_key, gkey: %s" % str(gkey))
logger.debug("** Calling runGPG with Running 'gpg %s --refresh-keys' for: %s"
% (' '.join(self.config.get_key('tasks', 'refresh-keys')), str(gkey)))
result = self.runGPG(task='refresh-keys', inputfile='')
logger.info('GPG return code: ' + str(result.returncode))
+ self.update_gkey(gkey, save=True)
return result
- def update_key(self, gkey, keydir):
+ def update_gkey(self, gkey, save=False):
'''Update the specified key in the specified keydir
@param key: tuple of (name, nick, keydir, fingerprint)
@param keydir: the keydir to add the key to
'''
- return []
+ # Update the gkey seed and save it to the installed db
+ lresults = []
+ for fpr in gkey.keys:
+ lresults.append(self.list_keys(gkey.keydir, fpr, colons=True))
+ self.seedfile.update(gkey.update(lresults))
+ if save and not self.seedfile.save():
+ logger.error("GkeysGPG.refresh_key(); failed to save seed: " + gkey.nick)
+ return False
+ return True
+
def list_keys(self, keydir, fingerprint=None, colons=False):
@@ -225,7 +235,7 @@ class GkeysGPG(GPG):
task = 'list-keys'
target = keydir
self.set_keydir(keydir, task, fingerprint=True)
- self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--with-fingerprint'])
+ self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint', '--fingerprint'])
if colons:
task_value = ['--with-colons']
self.config.options['tasks'][task].extend(task_value)
@@ -315,7 +325,7 @@ class GkeysGPG(GPG):
return results
- def set_keyseedfile(self, trap_errors):
+ def set_keyseedfile(self, trap_errors=True):
if not self.keydir:
logger.debug("GkeysGPG.set_keyseedfile(); self.keydir error")
self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'), self.config)