changeset: 6816:a3e35631b503
user: Kevin McCarthy <[email protected]>
date: Wed Oct 12 18:10:35 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/a3e35631b503
Handle presence of '--' delimiter in $sendmail. (closes #3168)
If the delimiter exists, additional sendmail flags will be inserted
before the delimiter. Any arguments after the delimiter will be
preserved as recipients.
diffs (87 lines):
diff -r 7c0995a61268 -r a3e35631b503 init.h
--- a/init.h Tue Oct 11 19:42:14 2016 -0700
+++ b/init.h Wed Oct 12 18:10:35 2016 -0700
@@ -2673,7 +2673,10 @@
** .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 },
/*
diff -r 7c0995a61268 -r a3e35631b503 sendlib.c
--- a/sendlib.c Tue Oct 11 19:42:14 2016 -0700
+++ b/sendlib.c Wed Oct 12 18:10:35 2016 -0700
@@ -2352,6 +2352,8 @@
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;
/* ensure that $sendmail is set to avoid a crash.
http://dev.mutt.org/trac/ticket/3548 */
@@ -2369,7 +2371,11 @@
safe_realloc (&args, sizeof (char *) * (argsmax += 5));
if (i)
+ {
+ if (!mutt_strcmp (ps, "--"))
+ break;
args[argslen++] = ps;
+ }
else
{
path = safe_strdup (ps);
@@ -2384,6 +2390,21 @@
i++;
}
+ /* 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");
@@ -2412,6 +2433,8 @@
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);
@@ -2425,7 +2448,7 @@
{
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));
@@ -2445,6 +2468,7 @@
FREE (&path);
FREE (&s);
FREE (&args);
+ FREE (&extra_args);
if (i == (EX_OK & 0xff))
i = 0;