summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2019-11-25 16:45:46 -0500
committerSean Whitton <spwhitton@spwhitton.name>2019-11-28 11:09:01 -0700
commitbb9373fcf4d6e462bc92927dd1bb8197d57c7b5a (patch)
treec4dc0ff7f9e2de590f767cc12948a9a865710a93
parent8b9826322916cab2c795f5325fa2922c8cd0f020 (diff)
downloadmailscripts-bb9373fcf4d6e462bc92927dd1bb8197d57c7b5a.tar.gz
email-print-mime-structure: Generic pipe decryption
No functional change. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> Acked-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-xemail-print-mime-structure6
1 files changed, 3 insertions, 3 deletions
diff --git a/email-print-mime-structure b/email-print-mime-structure
index cdbe2ee..6c68eb3 100755
--- a/email-print-mime-structure
+++ b/email-print-mime-structure
@@ -94,7 +94,7 @@ class MimePrinter(object):
if self.args.pgpkey:
cryptopayload = self.pgpy_decrypt(self.args.pgpkey, ciphertext)
if cryptopayload is None and self.args.use_gpg_agent:
- cryptopayload = self.gpg_decrypt(ciphertext)
+ cryptopayload = self.pipe_decrypt(ciphertext, ['gpg', '--batch', '--decrypt'])
if cryptopayload is None:
logging.warning(f'Unable to decrypt')
return
@@ -121,13 +121,13 @@ class MimePrinter(object):
pass
return None
- def gpg_decrypt(self, ciphertext:bytes) -> Optional[Message]:
+ def pipe_decrypt(self, ciphertext:bytes, cmd:List[str]) -> Optional[Message]:
inp:int
outp:int
inp, outp = os.pipe()
with open(outp, 'wb') as outf:
outf.write(ciphertext)
- out:subprocess.CompletedProcess[bytes] = subprocess.run(['gpg', '--batch', '--decrypt'],
+ out:subprocess.CompletedProcess[bytes] = subprocess.run(cmd,
stdin=inp,
capture_output=True)
if out.returncode == 0: