aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2015-12-12 16:47:20 -0800
committerBrian Dolbec <dolsen@gentoo.org>2015-12-12 16:47:20 -0800
commit0a37bd13ec85373a5a58cecaba11badf4ff6ba16 (patch)
tree2cd0042f63054fb2be9cfd76222369f0ae3dd2c8
parentgkeys: Set default verify-keyring, add verify-nick default (diff)
downloadgentoo-keys-0a37bd13ec85373a5a58cecaba11badf4ff6ba16.tar.gz
gentoo-keys-0a37bd13ec85373a5a58cecaba11badf4ff6ba16.tar.bz2
gentoo-keys-0a37bd13ec85373a5a58cecaba11badf4ff6ba16.zip
gkeysgpg/actions.py: Recode the sign() to replace this process with the gpg call
-rw-r--r--gkeys/gkeysgpg/actions.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/gkeys/gkeysgpg/actions.py b/gkeys/gkeysgpg/actions.py
index a25e1e4..f83ce86 100644
--- a/gkeys/gkeysgpg/actions.py
+++ b/gkeys/gkeysgpg/actions.py
@@ -77,6 +77,7 @@ class Actions(ActionBase):
'''
@param args: argparse.parse_args instance
+ @params argv: original command line args
'''
key = None
if args.dash: # stdin arg
@@ -155,13 +156,29 @@ class Actions(ActionBase):
return (results.returncode, results)
- def sign(self, args):
- '''Sign a file'''
- print("Made it to the --sign option :)")
- gkeyargs = Args()
- gkeyargs.filename = args.sign
- gkeys = gkeyActions(self.config, self.output, self.logger)
- return gkeys.sign(gkeyargs)
+ 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):