GPG.__init__(self, config)
self.config = config
self.keydir = keydir
+ self.task = None
+ self.task_value = None
+
+
+ def set_keypath(self, keyring, task=None):
+ logger.debug("keydir: %s, keyring: %s" % (self.keydir, keyring))
+ self.task = task
+ keypath = pjoin(self.keydir, keyring)
+ # --keyring file | Note that this adds a keyring to the current list.
+ # If the intent is to use the specified keyring alone,
+ # use --keyring along with --no-default-keyring.
+ self.task_value = ['--no-default-keyring', '--keyring', keypath]
+ task.extend(self.task_value)
+ return
+
+
+ def reset_task(self):
+ if self.task:
+ for item in self.task_value:
+ self.task.remove(item)
+ self.task = None
+ self.task_value = None
def add_key(self, gkey):
@param gkey: GKEY namedtuple with
(name, keyid/longkeyid, keyring, fingerprint,)
'''
- logger.debug("keydir: %s, keyring: %s" % (self.keydir, gkey.keyring))
- keypath = pjoin(self.keydir, gkey.keyring)
- # --keyring file | Note that this adds a keyring to the current list.
- # If the intent is to use the specified keyring alone,
- # use --keyring along with --no-default-keyring.
- self.config['tasks']['recv-keys'] = [
- '--no-default-keyring', '--keyring', keypath,
- ]
+ self.set_keypath(gkey.keyring, self.config['tasks']['recv-keys'])
+
# prefer the longkeyid if available
#logger.debug("LIB: add_key; keyids %s, %s"
# % (str(gkey.longkeyid), str(gkey.keyid)))
@param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
'''
- pass
+ return []
def del_keyring(self, keyring):
'''Delete the specified key to the specified keyring
'''
- pass
+ return []
def update_key(self, gkey, keyring):
@param key: tuple of (name, keyid, fingerprint)
@param keyring: the keyring to add the key to
'''
- pass
+ return []
- def list_keys(self, keyring=None):
+ def list_keys(self, keyring):
'''List all keys in the specified keyring or
all key in all keyrings if keyring=None
@param keyring: the keyring to add the key to
'''
- pass
+ if not keyring:
+ logger.debug("LIB: list_keys(), invalid keyring parameter: %s"
+ % str(keyring))
+ return []
+ if '--with-colons' in self.config['tasks']['list-keys']:
+ self.config['tasks']['list-keys'].remove('--with-colons')
+
+ self.set_keypath(keyring, self.config['tasks']['list-keys'])
+ logger.debug("** Calling runGPG with Running 'gpg %s --list-keys %s'"
+ % (' '.join(self.config['tasks']['list-keys']), keyring)
+ )
+ result = self.runGPG(task='list-keys', inputfile=keyring)
+ logger.info('GPG return code: ' + str(result.returncode))
+ self.reset_task()
+ return result
def list_keyrings(self):
'''List all available keyrings
'''
- pass
+ return []
def verify_key(self, gkey):