[neomutt-devel] [PATCH] send.c: Allow crypto operations in batch and mailx modes.

Alejandro Colomar alx at kernel.org
Fri Nov 10 01:53:55 CET 2023


On Fri, Nov 10, 2023 at 01:41:41AM +0100, Alejandro Colomar wrote:
> This is useful for signing patches with git-send-email(1).  Here's a
> working configuration for that:
> 
> In <~/.gitconfig>, add this section:
> 
> 	[sendemail]
> 		sendmailcmd = mutt -H -

A better approach for using git-send-email(1) with mutt(1) is:

	$ cat /usr/bin/mutt-as-mta
	#!/bin/sh
	mutt -H -

And then in <~/.gitconfig>:

	[sendemail]
		sendmailcmd = mutt-as-mta

This avoids duplicate TO and CCs.

> 
> After this patch, all patches sent with git-send-mail(1) will be signed
> (and even encrypted, if we have the public keys of all recipients and
> have enabled encryption when possible).
> 
> This is breaking behavior, so it needs some more justification than just
> the above.
> 
> This wasn't possible at all with mutt, and is a quite basic operation.
> With current mutt(1), you'd need to do trickery with mailboxes to be
> able to open patches with mutt in interactive mode and sign/encrypt
> them.  One could say don't use git-send-email(1), but then you still
> need to open mutt(1) interactively for sending signed mail.  It is
> very useful to be able to send a long series of patches or any other
> mail without interaction, and have it all signed.
> 
> The reason for not enabling this was for allowing running mutt(1) in
> cron jobs, or other cases where the keyring can't be unlocked.  This
> would still be possible after this patch, although it would need a
> change in the configuration.  Users should have a different
> configuration for such cron jobs that doesn't ask mutt(1) to use PGP.
> 
> Link: <https://github.com/neomutt/neomutt/issues/1471>
> Link: <https://github.com/neomutt/neomutt/pull/1476>
> Co-developed-by: Jenya Sovetkin <e.sovetkin at gmail.com>
> Cc: <neomutt-devel at neomutt.org>
> Signed-off-by: Alejandro Colomar <alx at kernel.org>
> ---
> 
> Hi!
> 
> I've been trying this patch for a few days with real patches sent to
> mailing lists, and it's been working great.  This same patch is sent
> with this patch (and the suggested git-send-email(1) configuration).
> 
> I based this patch on work from Jenya in neomutt(1), which has similar
> code, so the patch was easy to translate to mutt(1)'s code.
> 
> Here's how a log from git-send-email(1) looks like after this patch:
> 
> 	$ git send-email patches/0001-CONTRIBUTING-Please-sign-your-emails-with-PGP.patch
>         ...
> 	Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll): y
> 	Looking for keys matching "alx at kernel.org"...
> 	OK. Log says:
> 	Sendmail: mutt -H - -i alx at kernel.org
> 	From: Alejandro Colomar <alx at kernel.org>
> 	To: alx at kernel.org
> 	Subject: [PATCH] CONTRIBUTING: Please sign your emails with PGP
> 	Date: Fri, 10 Nov 2023 01:16:46 +0100
> 	Message-ID: <20231110001648.4787-1-alx at kernel.org>
> 	X-Mailer: git-send-email 2.42.0
> 	MIME-Version: 1.0
> 	Content-Transfer-Encoding: 8bit
> 
> 	Result: OK
> 
> I'm CCing neomutt(1), since I intend to send a similar patch to them.
> 
> Also, I only subscribed to mutt-dev@ recently, so this message may not
> arrive to the list.  If so, please bounce it yourself there.
> 
> Thanks!
> Alex
> 
> 
>  send.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/send.c b/send.c
> index 21ecf041..c98773fc 100644
> --- a/send.c
> +++ b/send.c
> @@ -2248,13 +2248,11 @@ static int send_message_resume_first_edit (SEND_CONTEXT *sctx)
>     * 2) pgp: header field was present during message editing with $edit_headers (sctx->msg->security != 0)
>     * 3) we are resending a message
>     * 4) we are recalling a postponed message (don't override the user's saved settings)
> -   * 5) we are in mailx mode
> -   * 6) we are in batch mode
>     *
>     * This is done after allowing the user to edit the message so that security
>     * settings can be configured with send2-hook and $edit_headers.
>     */
> -  if (WithCrypto && (sctx->msg->security == 0) && !(sctx->flags & (SENDBATCH | SENDMAILX | SENDPOSTPONED | SENDRESEND)))
> +  if (WithCrypto && (sctx->msg->security == 0) && !(sctx->flags & (SENDPOSTPONED | SENDRESEND)))
>    {
>      if (
>  #ifdef USE_AUTOCRYPT
> -- 
> 2.42.0
> 



-- 
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20231110/36e61560/attachment.sig>


More information about the neomutt-devel mailing list