path: root/gkeys
diff options
authorBrian Dolbec <dolsen@gentoo.org>2014-12-27 13:51:17 -0800
committerBrian Dolbec <dolsen@gentoo.org>2014-12-30 13:42:26 -0800
commit4a7e7e54a6b6ce280a221a0b039bebafd9d49701 (patch)
tree1b777d247b80c1ce70ff1446394015946e8c6231 /gkeys
parentgkeys/gkey.py: Add keys and uid fields, update() to GKEY (diff)
gkeys: Add keys and uid options to actions and seed handling
Add code to auto-update existing installed gkey.seeds files with the additional data.
Diffstat (limited to 'gkeys')
4 files changed, 38 insertions, 16 deletions
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 9baecaa..4a4f0eb 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -44,24 +44,24 @@ Available_Actions = General_Actions + Key_Actions + Seed_Actions
Action_Options = {
'list-cats': [],
- 'list-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', '1file'],
- 'add-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
- 'remove-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
- 'move-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'dest'],
- 'fetch-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
+ 'list-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file'],
+ 'add-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'uid'],
+ 'remove-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category'],
+ 'move-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'dest'],
+ 'fetch-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
'list-seedfiles': [],
- 'list-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
- 'install-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', '1file'],
- 'remove-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
- 'move-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
- 'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
- 'import-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
- 'key-search': ['nick', '1name', 'keydir', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
- 'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
- 'check-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+ 'list-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
+ 'install-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', '1file'],
+ 'remove-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+ 'move-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'dest'],
+ 'installed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+ 'import-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+ 'key-search': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
+ 'verify': ['dest', 'nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
+ 'check-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
- 'spec-check': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
- 'refresh-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+ 'spec-check': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
+ 'refresh-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
'---general---': [],
'----seeds----': [],
'----keys-----': [],
diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 541a12c..2c0e114 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -85,6 +85,12 @@ class CliBase(object):
help='The name of the keyring to use for verification, etc.')
+ def _option_keys(parser=None):
+ parser.add_argument('-K', '--keys', dest='keys', nargs='*',
+ default=None,
+ help='The name of the keyring to use for verification, etc.')
+ @staticmethod
def _option_nick(parser=None):
parser.add_argument('-n', '--nick', dest='nick', default=None,
help='The nick associated with the the key')
@@ -167,6 +173,11 @@ class CliBase(object):
action='store_true', default=False,
help='Just Do It')
+ @staticmethod
+ def _option_uid(parser=None):
+ parser.add_argument('-u', '--uid', dest='uid', nargs='*', default=None,
+ help='The user ID, gpg key uid')
def parse_args(self, args):
'''Parse a list of aruments
diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 16fe0fd..67354f3 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -57,6 +57,12 @@ class Seeds(object):
return False
for seed in list(seedlines.items()):
+ # GKEY class change auto-update
+ if not 'uid' in list(seed[1]):
+ seed[1]['uid'] = []
+ if not 'keys' in list(seed[1]):
+ seed[1]['keys'] = seed[1]['fingerprint'][:]
self.seeds[seed[0]] = GKEY(**seed[1])
#except Exception as err:
diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 33ed787..a9fb720 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -111,6 +111,11 @@ class SeedHandler(object):
if seed:
for nick in sorted(seed):
key = seed[nick]
+ # GKEY class change auto-update
+ if not 'uid' in list(key):
+ key['uid'] = []
+ if not 'keys' in list(key):
+ key['keys'] = key['fingerprint'][:]
seeds.add(nick, GKEY(**key))
except OSError as error:
self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir)