]> granicus.if.org Git - neomutt/commitdiff
Handle presence of '--' delimiter in $sendmail. (closes #3168)
authorKevin McCarthy <kevin@8t8.us>
Thu, 13 Oct 2016 01:10:35 +0000 (18:10 -0700)
committerRichard Russon <rich@flatcap.org>
Fri, 28 Oct 2016 10:12:20 +0000 (11:12 +0100)
If the delimiter exists, additional sendmail flags will be inserted
before the delimiter.  Any arguments after the delimiter will be
preserved as recipients.

init.h
sendlib.c

diff --git a/init.h b/init.h
index 461bc6cd5b962f7033cbef7d5fe82f48d481d139..d6c8be68bcafc53412c91075f0eb1238d75afa20 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2987,7 +2987,10 @@ struct option_t MuttVars[] = {
   ** .pp
   ** Specifies the program and arguments used to deliver mail sent by Mutt.
   ** Mutt expects that the specified program interprets additional
-  ** arguments as recipient addresses.
+  ** arguments as recipient addresses.  Mutt appends all recipients after
+  ** adding a \fC--\fP delimiter (if not already present).  Additional
+  ** flags, such as for $$use_8bitmime, $$use_envelope_from,
+  ** $$dsn_notify, or $$dsn_return will be added before the delimiter.
   */
   { "sendmail_wait",   DT_NUM,  R_NONE, UL &SendmailWait, 0 },
   /*
index cbc546a6c158225ff9c6fdb6d4a77cec7e906fdf..5441fa5136044ca5669a9fa8b807b40994a13cd8 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2404,6 +2404,8 @@ mutt_invoke_sendmail (ADDRESS *from,      /* the sender */
   char *ps = NULL, *path = NULL, *s = safe_strdup (Sendmail), *childout = NULL;
   char **args = NULL;
   size_t argslen = 0, argsmax = 0;
+  char **extra_args = NULL;
+  size_t extra_argslen = 0, extra_argsmax = 0;
   int i;
 
 #ifdef USE_NNTP
@@ -2438,7 +2440,11 @@ mutt_invoke_sendmail (ADDRESS *from,     /* the sender */
       safe_realloc (&args, sizeof (char *) * (argsmax += 5));
 
     if (i)
+    {
+      if (!mutt_strcmp (ps, "--"))
+        break;
       args[argslen++] = ps;
+    }
     else
     {
       path = safe_strdup (ps);
@@ -2457,6 +2463,21 @@ mutt_invoke_sendmail (ADDRESS *from,     /* the sender */
   if (!option (OPTNEWSSEND))
   {
 #endif
+  /* If Sendmail contained a "--", we save the recipients to append to
+   * args after other possible options added below. */
+  if (ps)
+  {
+    ps = NULL;
+    while ((ps = strtok (ps, " ")))
+    {
+      if (extra_argslen == extra_argsmax)
+        safe_realloc (&extra_args, sizeof (char *) * (extra_argsmax += 5));
+
+      extra_args[extra_argslen++] = ps;
+      ps = NULL;
+    }
+  }
+
   if (eightbit && option (OPTUSE8BITMIME))
     args = add_option (args, &argslen, &argsmax, "-B8BITMIME");
 
@@ -2485,6 +2506,8 @@ mutt_invoke_sendmail (ADDRESS *from,      /* the sender */
     args = add_option (args, &argslen, &argsmax, DsnReturn);
   }
   args = add_option (args, &argslen, &argsmax, "--");
+  for (i = 0; i < extra_argslen; i++)
+    args = add_option (args, &argslen, &argsmax, extra_args[i]);
   args = add_args (args, &argslen, &argsmax, to);
   args = add_args (args, &argslen, &argsmax, cc);
   args = add_args (args, &argslen, &argsmax, bcc);
@@ -2501,7 +2524,7 @@ mutt_invoke_sendmail (ADDRESS *from,      /* the sender */
   {
     if (i != S_BKG)
     {
-      const char *e = mutt_strsysexit (i);
+      const char *e;
 
       e = mutt_strsysexit (i);
       mutt_error (_("Error sending message, child exited %d (%s)."), i, NONULL (e));
@@ -2521,6 +2544,7 @@ mutt_invoke_sendmail (ADDRESS *from,      /* the sender */
   FREE (&path);
   FREE (&s);
   FREE (&args);
+  FREE (&extra_args);
 
   if (i == (EX_OK & 0xff))
     i = 0;