Attached is a patch to enable %a for all the pgp commands, except for pgp_getkeys_command (which is properly documented to only support %r).
There is a helper glue function, pgp_invoke(), that almost all the functions use. The fix was simply changing the signas parameter from NULL to PgpSignAs for each glue function invocation. For the one case that didn't call pgp_invoke(), pgp_import_command, I manually made the assignment. An alternative to this patch would be to remove the signas parameter from the glue function entirely, and simply hard code cctx.signas = PgpSignAs; in the glue function. However, I didn't feel quite as comfortable messing with function signatures for a simple patch. The patch should be low risk, as the cctx.signas is only used when evaluating %a, and most people use the stock pgp config commands. -Kevin
# HG changeset patch # User Kevin McCarthy <[email protected]> # Date 1403383898 25200 # Sat Jun 21 13:51:38 2014 -0700 # Node ID 46f26e444a3f643f02d5a65b9146ef26f8e96f9c # Parent 8f62001989cc9f564236e54b318ecca05f551af2 Enable %a format string for all pgp command configs. Currently, the documentation states that, with the exception of pgp_getkeys_command, all the PGP format commands should be available to the pgp_*_command configuration variables. However, the %a format is actually only enabled for pgp_clearsign_command, pgp_encrypt_sign_command, and pgp_sign_command. Philip Rinn discovered this problem when he was trying to add a "--encrypt-to %a" to pgp_encrypt_only_command. Rather than just fix the one configuration he was having the problem with, this patch enables %a usage for all of them. (With the exception of the documented pgp_getkeys_command.) diff --git a/pgpinvoke.c b/pgpinvoke.c --- a/pgpinvoke.c +++ b/pgpinvoke.c @@ -196,34 +196,34 @@ */ pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, short need_passphrase) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - need_passphrase, fname, NULL, NULL, NULL, + need_passphrase, fname, NULL, PgpSignAs, NULL, PgpDecodeCommand); } pid_t pgp_invoke_verify (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *sig_fname) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 0, fname, sig_fname, NULL, NULL, PgpVerifyCommand); + 0, fname, sig_fname, PgpSignAs, NULL, PgpVerifyCommand); } pid_t pgp_invoke_decrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 1, fname, NULL, NULL, NULL, PgpDecryptCommand); + 1, fname, NULL, PgpSignAs, NULL, PgpDecryptCommand); } pid_t pgp_invoke_sign (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, 1, fname, NULL, PgpSignAs, NULL, PgpSignCommand); @@ -235,17 +235,17 @@ const char *fname, const char *uids, int sign) { if (sign) return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, 1, fname, NULL, PgpSignAs, uids, PgpEncryptSignCommand); else return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 0, fname, NULL, NULL, uids, + 0, fname, NULL, PgpSignAs, uids, PgpEncryptOnlyCommand); } pid_t pgp_invoke_traditional (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, int flags) { if (flags & ENCRYPT) @@ -264,16 +264,17 @@ char _fname[_POSIX_PATH_MAX + SHORT_STRING]; char cmd[HUGE_STRING]; struct pgp_command_context cctx; memset (&cctx, 0, sizeof (cctx)); mutt_quote_filename (_fname, sizeof (_fname), fname); cctx.fname = _fname; + cctx.signas = PgpSignAs; mutt_pgp_command (cmd, sizeof (cmd), &cctx, PgpImportCommand); mutt_system (cmd); } void pgp_invoke_getkeys (ADDRESS *addr) { char buff[LONG_STRING]; @@ -314,26 +315,26 @@ close (devnull); } pid_t pgp_invoke_export (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 0, NULL, NULL, NULL, uids, + 0, NULL, NULL, PgpSignAs, uids, PgpExportCommand); } pid_t pgp_invoke_verify_key (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids) { return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 0, NULL, NULL, NULL, uids, + 0, NULL, NULL, PgpSignAs, uids, PgpVerifyKeyCommand); } pid_t pgp_invoke_list_keys (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, pgp_ring_t keyring, LIST *hints) { char uids[HUGE_STRING]; @@ -345,12 +346,12 @@ for (; hints; hints = hints->next) { mutt_quote_filename (quoted, sizeof (quoted), (char *) hints->data); snprintf (tmpuids, sizeof (tmpuids), "%s %s", uids, quoted); strcpy (uids, tmpuids); /* __STRCPY_CHECKED__ */ } return pgp_invoke (pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, - 0, NULL, NULL, NULL, uids, + 0, NULL, NULL, PgpSignAs, uids, keyring == PGP_SECRING ? PgpListSecringCommand : PgpListPubringCommand); }
signature.asc
Description: PGP signature
