[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeysgpg/

2018-07-06 Thread Brian Dolbec
commit: 17e3e3ad8ebb4e1590ebe801bf97af29dd066fba
Author: Brian Dolbec  gentoo  org>
AuthorDate: Mon Jul  2 21:39:16 2018 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sat Jul  7 05:22:11 2018 +
URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=17e3e3ad

gkeysgpg/cli.py: Fix doctring typos

Signed-off-by: Brian Dolbec  gentoo.org>

 gkeys/gkeysgpg/cli.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/gkeysgpg/cli.py b/gkeys/gkeysgpg/cli.py
index cdc984c..8d591f0 100644
--- a/gkeys/gkeysgpg/cli.py
+++ b/gkeys/gkeysgpg/cli.py
@@ -56,7 +56,7 @@ class Main(CliBase):
 def __call__(self, args=None):
 """Main class call function
 
-@param args: Optional list of argumanets to parse and action to run
+@param args: Optional list of arguments to parse and action to run
  Defaults to sys.argv[1:]
 """
 if args:
@@ -72,7 +72,7 @@ class Main(CliBase):
 def run(self, args):
 '''Run the gpg command option
 
-@param args: list of argumanets to parse
+@param args: list of arguments to parse
 '''
 # establish our actions instance
 self.actions = self.cli_config['Actions'](self.config, 
self.output_results, self.logger)



[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeysgpg/, gkeys/bin/

2015-12-25 Thread Brian Dolbec
commit: 474c437ce28b9d882aa4813dab289704b77a3b46
Author: Brian Dolbec  gentoo  org>
AuthorDate: Fri Dec 25 17:00:48 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Fri Dec 25 17:00:48 2015 +
URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=474c437c

gkeys-gpg: Make singing and other than verify actions work 

 gkeys/bin/gkeys-gpg   |  8 
 gkeys/gkeysgpg/actions.py | 39 +++
 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):

[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeysgpg/

2015-12-12 Thread Brian Dolbec
commit: 0a37bd13ec85373a5a58cecaba11badf4ff6ba16
Author: Brian Dolbec  gentoo  org>
AuthorDate: Sun Dec 13 00:47:20 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Sun Dec 13 00:47:20 2015 +
URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0a37bd13

gkeysgpg/actions.py: Recode the sign() to replace this process with the gpg call

 gkeys/gkeysgpg/actions.py | 31 ---
 1 file 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):



[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeysgpg/

2015-08-08 Thread Brian Dolbec
commit: 6d5462528d517f39e3ccadd332a9f45268430b36
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Sun Aug  9 04:53:41 2015 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Sun Aug  9 04:53:41 2015 +
URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=6d546252

gkeysgpg/cli: Fix a list copy

 gkeys/gkeysgpg/cli.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/gkeysgpg/cli.py b/gkeys/gkeysgpg/cli.py
index 70a898d..c5d08ec 100644
--- a/gkeys/gkeysgpg/cli.py
+++ b/gkeys/gkeysgpg/cli.py
@@ -40,7 +40,7 @@ class Main(CliBase):
 'Actions':  Actions,
 'Available_Actions': Available_Actions,
 'Action_Map': Action_Map,
-'Base_Options': Available_Actions.copy(),
+'Base_Options': Available_Actions[:],
 'prog': 'gkeys-gpg',
 'description': 'Gentoo-keys gpg command wrapper',
 'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to 
your system!'''