Add new command allow_from_override

When off, the --from option does not override the envelope-from address anymore.
This should solve https://github.com/marlam/msmtp-mirror/issues/51
pull/84/head
Martin Lambers 11 months ago
parent 58998f7d32
commit bab3844772
  1. 4
      NEWS
  2. 10
      doc/msmtp.1
  3. 12
      doc/msmtp.texi
  4. 25
      src/conf.c
  5. 3
      src/conf.h

@ -1,3 +1,7 @@
Version 1.8.20:
- Added a new configuration command 'allow_from_override'. When off, the --from
option does not override the envelope-from address anymore.
Version 1.8.19:
- Fixed a security problem in msmtpd: mail addresses starting with '-' could be
interpreted as options of the pipe command.

@ -148,7 +148,7 @@ option will choose the first account that has the given envelope-from address
(set with the \fBfrom\fP command). If no such account is found, "default" is
used.
.br
See the \fBfrom\fP command for substitution patterns supported in \fIaddress\fP.
See the \fBfrom\fP and \fBallow_from_override\fP commands.
.IP "\-N, \-\-dsn\-notify=(\fIoff\fP|\fIcond\fP)"
Set or unset DSN notification conditions. See the \fBdsn_notify\fP command.
.IP "\-R, \-\-dsn\-return=(\fIoff\fP|\fIret\fP)"
@ -553,11 +553,17 @@ the login name of the user running msmtp.
directory is used depending on the build configuration; see the output of msmtp
\-\-version and look for the location of the system configuration file).
.br
Note that the obsolete \fIauto_from\fP command replaces this envelope-from address.
Note that the obsolete \fBauto_from\fP command replaces this envelope-from address.
.br
To enforce the use of this envelope-from address and ignore the \-f / \-\-from option,
see the \fBallow_from_override\fP command.
.br
Furthermore, the envelope-from address may be a wildcard pattern as used for file name matching
in the shell. This is the case if it contains one of the characters ?, * or [.
This allows a variety of envelope-from addresses given with the \fI\-\-from\fP option to match a single account.
.IP "allow_from_override (\fIon\fP|\fIoff\fP)
By default, the \fI\-\-from\fP option overrides the \fBfrom\fP command.
Set to \fIoff\fP to disable this.
.IP "dsn_notify (\fIoff\fP|\fIcondition\fP)"
This command sets the condition(s) under which the mail system should send DSN
(Delivery Status Notification) messages. The argument \fIoff\fP disables

@ -373,11 +373,17 @@ the login name of the user running msmtp.
directory is used depending on the build configuration; see the output of
@samp{msmtp --version} and look for the location of the system configuration file).
@end itemize
Note that the obsolete @samp{auto_from} command replaces this envelope-from address.
Note that the obsolete @samp{auto_from} command replaces this envelope-from address.@*
To enforce the use of this envelope-from address and ignore the @samp{-f} / @samp{--from} option,
see @ref{allow_from_override}.@*
@xref{Envelope-from address}.@*
Furthermore, the envelope-from address may be a wildcard pattern as used for file name matching
in the shell. This is the case if it contains one of the characters @code{?}, @code{*} or @code{[}.
This allows a variety of envelope-from addresses given with the @samp{--from} option to match a single account.
@anchor{allow_from_override}
@item allow_from_override (on|off)
By default, the @ref{--from} option overrides the @ref{from} command.
Set to @samp{off} to disable this.
@anchor{dsn_notify}
@item dsn_notify (off|@var{condition})
@cmindex dsn_notify
@ -679,12 +685,11 @@ Set or unset minimum bit size of the Diffie-Hellman (DH) prime.
@itemx --from=@var{address}
@opindex -f
@opindex --from
Set the envelope-from address. @xref{from}.@*
Set the envelope-from address. See @ref{from} and @ref{allow_from_override}.@*
If no account was chosen yet (with @option{--account} or @option{--host}), this
option will choose the first account that has the given envelope-from address
(set with the @samp{from} command). If no such account is found, "default" is
used. @xref{Choosing an account}.@*
See the @samp{from} command for substitution patterns supported in @var{address}.
@anchor{--dsn-notify}
@item -N (off|@var{condition})
@itemx --dsn-notify=(off|@var{condition})
@ -1055,6 +1060,7 @@ part of the mail @emph{envelope}, not of the mail itself), but in most cases
both addresses are the same.
Envelope-from addresses are set with the @ref{from} command or @ref{--from} option.
The latter can be disabled with the @ref{allow_from_override} command.
@node Logging
@section Logging

@ -70,6 +70,7 @@ account_t *account_new(const char *conffile, const char *id)
a->timeout = 0;
a->protocol = SMTP_PROTO_SMTP;
a->domain = xstrdup("localhost");
a->allow_from_override = 1;
a->auto_from = 0;
a->from = NULL;
a->maildomain = NULL;
@ -130,6 +131,7 @@ account_t *account_copy(account_t *acc)
a->timeout = acc->timeout;
a->protocol = acc->protocol;
a->domain = acc->domain ? xstrdup(acc->domain) : NULL;
a->allow_from_override = acc->allow_from_override;
a->auto_from = acc->auto_from;
a->from = acc->from ? xstrdup(acc->from) : NULL;
a->maildomain = acc->maildomain ? xstrdup(acc->maildomain) : NULL;
@ -602,7 +604,7 @@ void override_account(account_t *acc1, account_t *acc2)
{
acc1->auto_from = acc2->auto_from;
}
if (acc2->mask & ACC_FROM)
if (acc1->allow_from_override && (acc2->mask & ACC_FROM))
{
free(acc1->from);
acc1->from = acc2->from ? xstrdup(acc2->from) : NULL;
@ -1420,6 +1422,27 @@ int read_conffile(const char *conffile, FILE *f, list_t **acc_list,
free(acc->from);
acc->from = xstrdup(arg);
}
else if (strcmp(cmd, "allow_from_override") == 0)
{
/* There is no mask value for this command since it can only
* occur in the configuration file, not on the command line */
if (is_on(arg))
{
acc->allow_from_override = 1;
}
else if (is_off(arg))
{
acc->allow_from_override = 0;
}
else
{
*errstr = xasprintf(
_("line %d: invalid argument %s for command %s"),
line, arg, cmd);
e = CONF_ESYNTAX;
break;
}
}
else if (strcmp(cmd, "auth") == 0)
{
acc->mask |= ACC_AUTH_MECH;

@ -4,7 +4,7 @@
* This file is part of msmtp, an SMTP client.
*
* Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2014,
* 2016, 2018, 2019, 2020
* 2016, 2018, 2019, 2020, 2021
* Martin Lambers <marlam@marlam.de>
* Martin Stenberg <martin@gnutiken.se> (passwordeval support)
* Scott Shumate <sshumate@austin.rr.com> (aliases support)
@ -102,6 +102,7 @@ typedef struct
int protocol; /* which SMTP sub protocol? */
char *domain; /* argument to EHLO command */
char *from; /* envelope from address */
int allow_from_override; /* flag: allow -f/--from to override from? */
int auto_from; /* obsolete: automatic envelope-from addresses? */
char *maildomain; /* obsolete: the domain part of generated
envelope from addresses */

Loading…
Cancel
Save