diff options
author | 2015-12-25 09:00:48 -0800 | |
---|---|---|
committer | 2015-12-25 09:00:48 -0800 | |
commit | 474c437ce28b9d882aa4813dab289704b77a3b46 (patch) | |
tree | 064d47e0d5dd4dfe8a71603a5ba46d8d2f000176 | |
parent | gkeys/actionbase.py: Add an exception to the raise statements (diff) | |
download | gentoo-keys-474c437ce28b9d882aa4813dab289704b77a3b46.tar.gz gentoo-keys-474c437ce28b9d882aa4813dab289704b77a3b46.tar.bz2 gentoo-keys-474c437ce28b9d882aa4813dab289704b77a3b46.zip |
gkeys-gpg: Make singing and other than verify actions work
-rwxr-xr-x | gkeys/bin/gkeys-gpg | 8 | ||||
-rw-r--r-- | gkeys/gkeysgpg/actions.py | 39 | ||||
-rw-r--r-- | gkeys/gkeysgpg/cli.py | 26 |
3 files changed, 32 insertions, 41 deletions
diff --git a/gkeys/bin/gkeys-gpg b/gkeys/bin/gkeys-gpg index 3bed18f..f064b14 100755 --- a/gkeys/bin/gkeys-gpg +++ b/gkeys/bin/gkeys-gpg @@ -28,6 +28,14 @@ import os import sys +if '--verify' not in sys.argv: + # we are not verifying now, just call out to the normal + # gpg with args exactly as we were called with + sys.argv[0] = '/usr/bin/gpg' + os.execvp('/usr/bin/gpg', sys.argv) + sys.exit(1) + + # This block ensures that ^C interrupts are handled quietly. try: import signal diff --git a/gkeys/gkeysgpg/actions.py b/gkeys/gkeysgpg/actions.py index f83ce86..51f6a6a 100644 --- a/gkeys/gkeysgpg/actions.py +++ b/gkeys/gkeysgpg/actions.py @@ -12,6 +12,7 @@ from __future__ import print_function +import re import sys if sys.version_info[0] >= 3: @@ -26,7 +27,7 @@ from snakeoil.demandload import demandload from gkeys.actions import Actions as gkeyActions from gkeys.actionbase import ActionBase -from gkeys.base import Args +from pyGPG.gpg import GPG demandload( "json:load", @@ -36,15 +37,6 @@ demandload( Action_Map = OrderedDict([ - ('sign', { - 'func': 'sign', - 'options': ['nick', 'name', 'fingerprint', ], - 'desc': '''Sign a file''', - 'long_desc': '''Sign a file with the designated gpg key. - The default sign settings can be set in gpg.conf. These settings can be - overridden on the command line using the 'nick', 'name', 'fingerprint' options''', - 'example': '''gkeys-gpg --sign foo''', - }), ('verify', { 'func': 'verify', 'options': [], @@ -59,7 +51,7 @@ Action_Map = OrderedDict([ }), ]) -Available_Actions = ['sign', 'verify'] +Available_Actions = ['verify'] class Actions(ActionBase): @@ -156,31 +148,6 @@ class Actions(ActionBase): return (results.returncode, results) - def sign(self, args, argv): - '''Sign a file using gnupg's gpg command, replacing the current process''' - cmd = ['usr/bin/gpg'] - cmd.extend(argv) - for stream in (sys.__stdout__, sys.__stderr__): - stream.flush() - - try: - pid = os.fork() - if pid == 0: - # A second fork is required in order to create an - # "orphan" process that will be reaped by init. - pid = os.fork() - if pid == 0: - os.setsid() - os._exit(0) - - os.waitpid(pid, 0) - os.execv(cmd[0], cmd) - except Exception: - traceback.print_exc() - finally: - os._exit(1) - - def _committer_search(self, data): username = None nick = None diff --git a/gkeys/gkeysgpg/cli.py b/gkeys/gkeysgpg/cli.py index c5d08ec..cdc984c 100644 --- a/gkeys/gkeysgpg/cli.py +++ b/gkeys/gkeysgpg/cli.py @@ -45,7 +45,8 @@ class Main(CliBase): 'description': 'Gentoo-keys gpg command wrapper', 'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to your system!''' } - self.cli_config['Base_Options'].extend(["dash", "statusfd"]) + self.cli_config['Base_Options'].extend(["armor", "clearsign", "dash", + "detachsign", "statusfd", "user"]) self.cli_config['Base_Options'].extend(KEY_OPTIONS) self.cli_config['Base_Options'].extend(["category"]) self.version = __version__ @@ -101,23 +102,38 @@ class Main(CliBase): help='fill me in') @staticmethod + def _option_armor(parser=None): + parser.add_argument('-a', '--armor', dest='armor', + action='store_true', + help='Create ASCII armored output. The default is to create the binary OpenPGP format.') + + @staticmethod def _option_clearsign(parser=None): - parser.add_argument('--clearsign', dest='clearsign', default=None, + parser.add_argument('--clearsign', dest='clearsign', + action='store_true', default=None, help='make a clear text signature') @staticmethod def _option_detachsign(parser=None): - parser.add_argument('-b', '--detach-sign', dest='detachsign', default=None, + parser.add_argument('-b', '--detach-sign', dest='detachsign', + action='store_true', default=None, help='make a detached signature') @staticmethod def _option_sign(parser=None): - parser.add_argument('-s', '--sign', dest='sign', default=None, + parser.add_argument('-s', '--sign', dest='sign', + action='store_true', default=None, help='make a signature') @staticmethod + def _option_user(parser=None): + parser.add_argument('-u', '--local-user', dest='user', default=None, + help='Use name as the key to sign with.') + + @staticmethod def _option_verify(parser=None): - parser.add_argument('--verify', dest='verify', default=None, + parser.add_argument('--verify', dest='verify', + action='store_true', default=None, help='verify a signature') ### These are for gpg command compatibilty only |