From 47d935d1ace2c1bc4166c20587390728e2cf0361 Mon Sep 17 00:00:00 2001 From: juga0 Date: Sun, 12 Nov 2017 17:04:51 +0000 Subject: [PATCH] Add variable to specify gpg binary path and substitute hardcoded gpg command. It should check which version of gpg is installed... --- corpus/OpenPGP/gnupg-import | 6 ++++-- generators/generator.py | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/corpus/OpenPGP/gnupg-import b/corpus/OpenPGP/gnupg-import index a92bce2..71a9b82 100755 --- a/corpus/OpenPGP/gnupg-import +++ b/corpus/OpenPGP/gnupg-import @@ -1,5 +1,7 @@ #!/bin/bash +GPG=gpg + mkdir -p -m 0700 GNUPGHOME export GNUPGHOME=$(pwd)/GNUPGHOME @@ -9,7 +11,7 @@ no-allow-external-cache EOF for x in winston obrian julia; do - <$x.key gpg2 --batch --pinentry-mode=loopback --passphrase=_${x}_ --import + <$x.key $(GPG) --batch --pinentry-mode=loopback --passphrase=_${x}_ --import done # mark all keys with ultimate ownertrust. This is a silly hack, but @@ -20,7 +22,7 @@ done # pragmatically handle all the secret keys in a single homedir. For # now, we're opting for the latter. -gpg2 --import-ownertrust < @@ -81,8 +83,8 @@ def render_mime_structure(z, prefix='└', stream=sys.stdout): subject = '' if (z.is_multipart()): print(prefix + '┬╴' + z.get_content_type() + cset + - disposition + fname, z.as_string().__len__().__str__() - + ' bytes' + subject, file=stream) + disposition + fname, z.as_string().__len__().__str__() + + ' bytes' + subject, file=stream) if prefix.endswith('└'): prefix = prefix.rpartition('└')[0] + ' ' if prefix.endswith('├'): @@ -146,7 +148,7 @@ def get_password_from(self): def sign(self,body,sender=None): if not sender: sender = self.get('From') - g = subprocess.Popen(['gpg2', '--batch', + g = subprocess.Popen([GPG, '--batch', '--homedir=corpus/OpenPGP/GNUPGHOME', '--pinentry-mode=loopback', '--passphrase', self.get_password_from(), @@ -180,7 +182,7 @@ def sign(self,body,sender=None): def encrypt(self,body, sign=False): - args = ['gpg2', '--batch', + args = [GPG, '--batch', '--homedir=corpus/OpenPGP/GNUPGHOME', '--no-emit-version', '--armor', @@ -241,4 +243,3 @@ def main(self): if self.extended_description: print(self.extended_description, file=descstream) render_mime_structure(self, stream=descstream) -