From bb9373fcf4d6e462bc92927dd1bb8197d57c7b5a Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Mon, 25 Nov 2019 16:45:46 -0500 Subject: email-print-mime-structure: Generic pipe decryption No functional change. Signed-off-by: Daniel Kahn Gillmor Acked-by: Sean Whitton --- email-print-mime-structure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'email-print-mime-structure') 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: -- cgit v1.2.3