Skip to content

Commit

Permalink
gkeysgpg/actions.py: Recode the sign() to replace this process with t…
Browse files Browse the repository at this point in the history
…he gpg call
  • Loading branch information
dol-sen committed Dec 13, 2015
1 parent 1a96292 commit 0a37bd1
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions gkeys/gkeysgpg/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def verify(self, args, argv):

'''
@param args: argparse.parse_args instance
@params argv: original command line args
'''
key = None
if args.dash: # stdin arg
Expand Down Expand Up @@ -155,13 +156,29 @@ def verify(self, args, argv):
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):
Expand Down

0 comments on commit 0a37bd1

Please sign in to comment.