diff options
author | Tails developers <amnesia@boum.org> | 2012-08-18 16:03:30 +0200 |
---|---|---|
committer | Tails developers <amnesia@boum.org> | 2012-08-18 18:39:44 +0200 |
commit | 8f4e7be6169744b41aca025cc695569ed7148de3 (patch) | |
tree | eabd4c585c682b417c7a144e8731efd9914f949d | |
parent | ba27f492e749a55c252aa27552349c309610d217 (diff) |
Allow to use arbitrary gnupg homdir
-rw-r--r-- | doc/config.py.sample | 8 | ||||
-rw-r--r-- | whisperBack/encryption.py | 5 | ||||
-rw-r--r-- | whisperBack/whisperback.py | 5 |
3 files changed, 15 insertions, 3 deletions
diff --git a/doc/config.py.sample b/doc/config.py.sample index 7b60301..38752ac 100644 --- a/doc/config.py.sample +++ b/doc/config.py.sample @@ -45,6 +45,14 @@ a public PGP key enables us to encrypt such future communication.</p> """) +# KEYRING +# +# This section defines keyring parameters + +# The path to the OpenPGP home directory to use. If None, use OpenPGP default +# $GUNPGHOME +gnupg_homedir = None + # RECIPIENT # # This section defines the recepient parameters diff --git a/whisperBack/encryption.py b/whisperBack/encryption.py index d710457..e758803 100644 --- a/whisperBack/encryption.py +++ b/whisperBack/encryption.py @@ -24,6 +24,7 @@ """Some tools for encryption """ +import os import pyme.core import pyme.errors @@ -33,9 +34,11 @@ import whisperBack.exceptions class Encryption (object): """Some tools for encryption""" - def __init__ (self): + def __init__ (self, gnupg_homedir=None): """Initialize the encryption mechanism""" + if gnupg_homedir and os.path.exists(gnupg_homedir): + os.environ["GNUPGHOME"] = gnupg_homedir self.context = pyme.core.Context() def __fingerprints_to_keys (self, fingerprints): diff --git a/whisperBack/whisperback.py b/whisperBack/whisperback.py index 1fe996b..a7810d4 100644 --- a/whisperBack/whisperback.py +++ b/whisperBack/whisperback.py @@ -97,6 +97,7 @@ class WhisperBack(object): # Initialize config variables self.html_help = "" + self.gnupg_homedir = None self.to_address = None self.to_fingerprint = None self.from_address = None @@ -242,8 +243,8 @@ class WhisperBack(object): def get_encrypted_message_body(self): """Returns the encrypted body of the email to be send""" - return whisperBack.encryption.Encryption().encrypt(self.get_message_body(), - [self.to_fingerprint]) + encryption = whisperBack.encryption.Encryption(gnupg_homedir=self.gnupg_homedir) + return encryption.encrypt(self.get_message_body(), [self.to_fingerprint]) def save(self, path): """Save the message into a file |