From e910230a9fb8a5151bede6d043679ec50570290f Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sat, 9 Nov 2019 16:48:14 -0500 Subject: email-print-mime-structure: Add --use-gpg-agent for decryption In some cases, the user may want to try to use their own GnuPG secret keys to decrypt encrypted parts of the message. By default it is disabled so that we aren't accidentally triggering the use of user secret key material. Note that gpg(1) says: It is highly recommended to use [--batch] along with the options --status-fd and --with-colons for any unattended use of gpg. I am deliberately choosing to not use either --status-fd or --with-colons for email-print-mime-structure. I'm not using --with-colons because there is no output from GnuPG that we expect to be machine-readable -- we're just looking for the cleartext of whatever ciphertext is in the message part. I'm not using --status-fd because there is nothing actionable we can do with GnuPG status messages, and asking for them would require switching from subprocess.run to subprocess.Popen to take advantage of the pass_fds argument, which in turn would make the script only work in a POSIX environment (I believe, but have not tested, that the script can currently be used on Windows). Signed-off-by: Daniel Kahn Gillmor --- email-print-mime-structure.1.pod | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'email-print-mime-structure.1.pod') diff --git a/email-print-mime-structure.1.pod b/email-print-mime-structure.1.pod index b846d87..69b1cdc 100644 --- a/email-print-mime-structure.1.pod +++ b/email-print-mime-structure.1.pod @@ -29,6 +29,25 @@ standard input, this key will be tried for decryption. May be used multiple times if you want to try decrypting with more than one secret key. +OpenPGP secret keys listed in B<--pgpkey=> are used ephemerally, and +do not interact with any local GnuPG keyring. + +=item B<--use-gpg-agent=>I|I + +If I, and B encounters a +PGP/MIME-encrypted part, it will try to decrypt the part using the +secret keys found in the local installation of GnuPG. (default: +I) + +If both B<--pgpkey=>I and B<--use-gpg-agent=true> are +supplied, I arguments will be tried before falling back to +GnuPG. + +If B has been asked to decrypt parts with +either B<--pgpkey=>I or with B<--use-gpg-agent=true>, and it +is unable to decrypt an encrypted part, it will emit a warning to +stderr. + =item B<--help>, B<-h> Show usage instructions. @@ -49,11 +68,6 @@ Show usage instructions. =head1 LIMITATIONS -B only decrypts encrypted e-mails using -raw, non-password-protected OpenPGP secret keys (see B<--pgpkey>, -above). If it is unable to decrypt an encrypted part with the -supplied keys, it will warn on stderr. - B's output is not stable, and is not intended to be interpreted by machines, so please do not depend on it in scripts! -- cgit v1.2.3