aboutsummaryrefslogtreecommitdiff
path: root/slave
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-10-14 18:23:04 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-10-14 18:35:06 +0530
commit9a01c2e99e89160386d697fa8851d1d1554b8cb2 (patch)
tree87f97f139cde0371d9441e579ca3947c4c59ec16 /slave
parentMake it a bit more obvious that AutotuA is a palindrome :p (diff)
downloadautotua-9a01c2e99e89160386d697fa8851d1d1554b8cb2.tar.gz
autotua-9a01c2e99e89160386d697fa8851d1d1554b8cb2.tar.bz2
autotua-9a01c2e99e89160386d697fa8851d1d1554b8cb2.zip
[bugfix] Don't check gpghome while init_gpghome()
This is the kind of bug that is easy to miss without proper testing :) init_gpghome() would never work because it would check if self.gpghome was a valid gpghome before creating it :p Reported by Anielkis Herrera González (p0w3r3d)
Diffstat (limited to 'slave')
-rw-r--r--slave/autotua/crypt/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/slave/autotua/crypt/__init__.py b/slave/autotua/crypt/__init__.py
index bb97d17..29e37f3 100644
--- a/slave/autotua/crypt/__init__.py
+++ b/slave/autotua/crypt/__init__.py
@@ -20,6 +20,8 @@ class Crypto(object):
self.gpghome = gpghome
self.gpgcmd = 'gpg -a --keyid-format long --trust-model always '
self.gpgcmd += '--homedir="%s" ' % self.gpghome
+
+ def _validate_gpghome(self):
if not os.path.exists(self.gpghome+'/secring.gpg'):
raise Exception('"%s": Invalid GPG homedir' % self.gpghome)
@@ -36,11 +38,13 @@ class Crypto(object):
return line.split(':')[-2]
def export_pubkey(self, file, which):
+ self._validate_gpghome()
gpg_args = '--export "%s" > "%s"' % (which, file)
print self.gpgcmd+gpg_args
subprocess.check_call(self.gpgcmd+gpg_args, shell=True)
def import_pubkey(self, pubkey):
+ self._validate_gpghome()
gpg_args = '--import <<<"%s"' % pubkey
subprocess.check_call(self.gpgcmd+gpg_args, shell=True)
@@ -75,6 +79,7 @@ class Crypto(object):
returns: encrypted_data
"""
+ self._validate_gpghome()
gpg_args = '--encrypt --sign --recipient "%s" <<<"%s"' % (recipient, data)
process = subprocess.Popen(self.gpgcmd+gpg_args, shell=True,
stdout=subprocess.PIPE)
@@ -91,6 +96,7 @@ class Crypto(object):
returns: (decrypted_data, sender)
"""
+ self._validate_gpghome()
gpg_args = '--decrypt <<<"%s"' % data
process = subprocess.Popen(self.gpgcmd+gpg_args, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)