diff options
author | aeroniero33 <justthisthing@gmail.com> | 2016-06-21 01:40:28 +0000 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2018-07-06 22:22:08 -0700 |
commit | e5e8dcd1e4484a25ba6f15b0cff2f4c943291237 (patch) | |
tree | 80b247120675aedc38fab9bd11c70a9fcb4af75f | |
parent | Implemented the email reminders in spec-check (diff) | |
download | gentoo-keys-e5e8dcd1e4484a25ba6f15b0cff2f4c943291237.tar.gz gentoo-keys-e5e8dcd1e4484a25ba6f15b0cff2f4c943291237.tar.bz2 gentoo-keys-e5e8dcd1e4484a25ba6f15b0cff2f4c943291237.zip |
Created the send-key function
-rw-r--r-- | gkeys/gkeys/action_map.py | 11 | ||||
-rw-r--r-- | gkeys/gkeys/actions.py | 27 | ||||
-rw-r--r-- | gkeys/gkeys/lib.py | 16 |
3 files changed, 53 insertions, 1 deletions
diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index e4ea412..f372a5c 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -18,7 +18,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed', 'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed'] Key_Actions = ['----keys-----', 'check-key', 'installed', - 'install-key', 'list-key', 'refresh-key', 'remove-key', + 'install-key', 'list-key', 'send-key', 'refresh-key', 'remove-key', 'search-key', 'spec-check'] General_Actions = ['---general---', 'list-cats', 'sign','verify'] @@ -174,6 +174,15 @@ Gpg info.: pub 4096R/825533CBF6CD6C97 2014-10-03 [expires: 2017-09-17] Gkey task results: Done.''', }), + ('send-key', { + 'func': 'sendkey', + 'options': ['category', 'nick', 'name', 'fingerprint', 'keyid', 'keys', + 'keydir', 'keyring'], + 'desc': '''Uploads the selected gpg key''', + 'long_desc': '''Uploads the selected gpg key''', + 'example': '''gkeys send-key -C gentoo -n gkeys''', + }), + ('move-key', { 'func': 'movekey', 'options': ['category', 'nick', 'name', 'fingerprint', 'keys', diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index fb36719..815ea43 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -194,6 +194,33 @@ class Actions(ActionBase): return (False, messages) + def sendkey(self, args): + '''Send selected key(s) to the server''' + if not args.category: + return (False, ["Please specify seeds type."]) + self.logger.debug(_unicode("ACTIONS: sendkey; args: %s") + % _unicode(args)) + seeds = self.seedhandler.load_category(args.category, refresh=True) + self.category = args.category + results = {} + kwargs = self.seedhandler.build_gkeydict(args) + keyresults = seeds.list(**kwargs) + if keyresults: + self.output('', '\n sending keys...') + else: + return (False, ["Key(s) not found"]) + for gkey in sorted(keyresults): + self.logger.info(_unicode("Sending key %s, %s") + % (gkey.nick, gkey.pub_keyid)) + self.output('', _unicode(" %s: %s") + % (gkey.name, ', '.join(gkey.pub_keyid))) + self.logger.debug(_unicode("ACTIONS: sendkey; gkey = %s") + % _unicode(gkey)) + results[gkey.keydir] = self.gpg.send_keys(gkey) + return (True, ['Completed']) + + + def listkey(self, args): '''Pretty-print the selected gpg key''' # get confirmation diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 5ad1aab..a8529f4 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -273,6 +273,22 @@ class GkeysGPG(GPG): self.logger.info('GPG return code: ' + str(result.returncode)) return result + def send_keys(self, gkey): + '''Send gkey to keyserver + @param gkey: the gkey to be sent to the server + @return: GKEY_CHECK instance + ''' + self.config.defaults['gpg_defaults'].append('--no-permission-warning') + self.set_keyserver() + self.set_keydir(gkey.keydir, 'send-keys', reset=True) + self.set_keyring('pubring.gpg', 'send-keys', reset=False) + self.set_keyseedfile(refresh=True) + self.logger.debug("LIB: send-keys, gkey: %s" % str(gkey)) + self.logger.debug("** Calling runGPG with Running 'gpg %s --send-keys' for: %s" + % (' '.join(self.config.get_key('tasks', 'send-keys')), str(gkey))) + result = self.runGPG(task='send-keys', inputfile='') + self.logger.info('GPG return code: ' + str(result.returncode)) + return result def check_keys(self, keydir, keyid, result=None): '''Check specified or all keys based on the seed type |