[Pkg-privacy-commits] [monkeysign] 01/01: basic tor support, to be tested
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:34:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch dev/tor
in repository monkeysign.
commit 46ce7ade997be07d7a3d4d4412e427a60130816c
Author: Antoine Beaupré <anarcat at koumbit.org>
Date: Tue Oct 1 15:20:08 2013 +0200
basic tor support, to be tested
---
monkeysign/gpg.py | 15 +++++++++++----
monkeysign/ui.py | 10 ++++++----
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/monkeysign/gpg.py b/monkeysign/gpg.py
index 88769b0..f5fc737 100644
--- a/monkeysign/gpg.py
+++ b/monkeysign/gpg.py
@@ -248,6 +248,10 @@ class Context():
m = re.search('gpg \(GnuPG\) (\d+.\d+(?:.\d+)*)', self.stdout)
return m.group(1)
+class TorContext(Context):
+ def build_command(self, command):
+ return ['torsocks'] + Context.build_command(command)
+
class Keyring():
"""Keyring functionalities.
@@ -267,7 +271,7 @@ class Keyring():
# the context this keyring is associated with
context = None
- def __init__(self, homedir=None):
+ def __init__(self, homedir=None, usetor=False):
"""constructor for the gpg context
this mostly sets options, and allows passing in a different
@@ -278,7 +282,10 @@ class Keyring():
later function calls on the object may modify the keyring (or
other keyrings, if the homedir option is modified.
"""
- self.context = Context()
+ if usetor:
+ self.context = TorContext()
+ else:
+ self.context = Context()
if homedir is not None:
self.context.set_option('homedir', homedir)
else:
@@ -526,10 +533,10 @@ class Keyring():
return proc.wait() == 0
class TempKeyring(Keyring):
- def __init__(self):
+ def __init__(self, usetor=False):
"""Override the parent class to generate a temporary GPG home
that gets destroyed at the end of operations."""
- Keyring.__init__(self, tempfile.mkdtemp(prefix="pygpg-"))
+ Keyring.__init__(self, tempfile.mkdtemp(prefix="pygpg-"), usetor)
def __del__(self):
shutil.rmtree(self.homedir)
diff --git a/monkeysign/ui.py b/monkeysign/ui.py
index 19fdef8..0355830 100644
--- a/monkeysign/ui.py
+++ b/monkeysign/ui.py
@@ -85,6 +85,8 @@ class MonkeysignUi(object):
parser.add_option('--smtppass', dest='smtppass', help=_('password for the SMTP server (default: prompted, if --smtpuser is specified)'))
parser.add_option('--no-mail', dest='nomail', default=False, action='store_true',
help=_('Do not send email at all. (Default is to use sendmail.)'))
+ parser.add_option('--tor', dest='usetor', default=False, action='store_true',
+ help=_('Use torsocks to fetch keys from the keyserver'))
parser.add_option('-t', '--to', dest='to',
help=_('Override destination email for testing (default is to use the first uid on the key or send email to each uid chosen)'))
return parser
@@ -111,9 +113,6 @@ class MonkeysignUi(object):
# the key we are signing, can be a keyid or a uid pattern
self.pattern = None
- # the regular keyring we suck secrets and maybe the key to be signed from
- self.keyring = Keyring()
-
# the temporary keyring we operate in, actually initialized in prepare()
# this is because we want the constructor to just initialise
# data structures and not write any data
@@ -127,6 +126,9 @@ class MonkeysignUi(object):
self.parse_args(args)
+ # the regular keyring we suck secrets and maybe the key to be signed from
+ self.keyring = Keyring(usetor=self.options.usetor)
+
# set a default logging mechanism
self.logfile = sys.stderr
self.log(_('Initializing UI'))
@@ -147,7 +149,7 @@ class MonkeysignUi(object):
def prepare(self):
# initialize the temporary keyring directory
- self.tmpkeyring = TempKeyring()
+ self.tmpkeyring = TempKeyring(usetor=self.options.usetor)
if self.options.debug:
self.tmpkeyring.context.debug = self.logfile
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/monkeysign.git
More information about the Pkg-privacy-commits
mailing list