Gilles Chehade (2019-05-19 14:31+0200):
On Sun, May 19, 2019 at 12:16:40PM +0200, David Flatz wrote:
Gilles Chehade (2019-05-19 10:39+0200):
> On Sun, May 19, 2019 at 10:24:07AM +0200, Gilles Chehade wrote:
> > On Sat, May 18, 2019 at 02:55:05PM +0200, David Flatz wrote:
> > > Delivery to dovecot works pretty good for normal mails locally with
sendmail
> > > and from remote. However, when opensmtpd generates a bounce dovecot won't
> > > accept it and returns following error message "501 5.5.4 Invalid FROM:
> > > Missing domain".
> > >
> > > [...]
> > >
> > > It seems like opensmtpd uses an envelope from for the bounces that dovecot
> > > doesn't like. Is there a way to make opensmtpd to either use an empty
> > > envelope from (since those seem fine to dovecot) or add a domain?
> > >
> > > Thanks again and have a great weekend!
> > >
> >
> > Yup, the fix will be committed to -current today
> >
>
> can you test the following diff and tell me if it makes things better ?
>
> it essentially reverts a commit from months ago which we thought was the
> proper way to deal with this, but was actually made necessary because of
> another issue in mda_variables.c
>
> I think this diff should properly fix your issue.
>
> [...]
Thanks for the diff. I get this error with a similar diff (I'm using
portable 6.4.1p2):
smtpd[6600]: 0000000000000000 mda delivery evpid=4bbf012508df6894 from=<> to=<[email protected]>
rcpt=<[email protected]> user=username delay=0s result=PermFail stat=Error ("smtpd: No such file or
directorymda command line could not be expanded")
[...]
care to try building from the github repo ?
my diff assumes a previous fix to mda_variables.c:
https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/smtpd/mda_variables.c.diff?r1=1.4&r2=1.5&f=h
"""
in mda variables expansions, do not consider empty strings as errors since
an empty %{sender} is really a mailer-daemon and not an error
reported and initial diff by Lauri Tirkkonen <[email protected]>
commit is a revised version of the diff based on a discussion with eric@
"""
It was committed five months ago, after 6.4.1p2 which is why you get the
error with my new diff.
Most recent portable from github segfaulted for me so I backported that
fix to 6.4.1p2.
With the following diff bounces get accepted by dovecot.
--- smtpd/parse.y
+++ smtpd/parse.y
@@ -617,11 +617,11 @@
} dispatcher_local_options
| LMTP STRING {
asprintf(&dispatcher->u.local.command,
- PATH_LIBEXEC"/mail.lmtp -f %%{mbox.from} -d %s %%{user.username}",
$2);
+ PATH_LIBEXEC"/mail.lmtp -f \"%%{sender}\" -d %s %%{user.username}",
$2);
} dispatcher_local_options
| LMTP STRING RCPT_TO {
asprintf(&dispatcher->u.local.command,
- PATH_LIBEXEC"/mail.lmtp -f %%{mbox.from} -d %s %%{dest}", $2);
+ PATH_LIBEXEC"/mail.lmtp -f \"%%{sender}\" -d %s %%{dest}", $2);
} dispatcher_local_options
| MDA STRING {
asprintf(&dispatcher->u.local.command,
--- smtpd/mda_variables.c
+++ smtpd/mda_variables.c
@@ -36,9 +36,9 @@
#define EXPAND_DEPTH 10
-size_t mda_expand_format(char *, size_t, const struct deliver *,
+ssize_t mda_expand_format(char *, size_t, const struct deliver *,
const struct userinfo *, const char *);
-static size_t mda_expand_token(char *, size_t, const char *,
+static ssize_t mda_expand_token(char *, size_t, const char *,
const struct deliver *, const struct userinfo *, const char *);
static int mod_lowercase(char *, size_t);
static int mod_uppercase(char *, size_t);
@@ -56,7 +56,7 @@
#define MAXTOKENLEN 128
-static size_t
+static ssize_t
mda_expand_token(char *dest, size_t len, const char *token,
const struct deliver *dlv, const struct userinfo *ui, const char
*mda_command)
{
@@ -75,14 +75,14 @@
mods = NULL;
if (strlcpy(rtoken, token, sizeof rtoken) >= sizeof rtoken)
- return 0;
+ return -1;
/* token[x[:y]] -> extracts optional x and y, converts into offsets */
if ((lbracket = strchr(rtoken, '[')) &&
(rbracket = strchr(rtoken, ']'))) {
/* ] before [ ... or empty */
if (rbracket < lbracket || rbracket - lbracket <= 1)
- return 0;
+ return -1;
*lbracket = *rbracket = '\0';
content = lbracket + 1;
@@ -102,7 +102,7 @@
}
}
if (errstr)
- return 0;
+ return -1;
/* token:mod_1,mod_2,mod_n -> extract modifiers */
mods = strchr(rbracket + 1, ':');
@@ -115,7 +115,7 @@
if (!strcasecmp("sender", rtoken)) {
if (snprintf(tmp, sizeof tmp, "%s@%s",
dlv->sender.user, dlv->sender.domain) >= (int)sizeof
tmp)
- return 0;
+ return -1;
if (strcmp(tmp, "@") == 0)
(void)strlcpy(tmp, "", sizeof tmp);
string = tmp;
@@ -123,7 +123,7 @@
else if (!strcasecmp("rcpt", rtoken)) {
if (snprintf(tmp, sizeof tmp, "%s@%s",
dlv->rcpt.user, dlv->rcpt.domain) >= (int)sizeof tmp)
- return 0;
+ return -1;
if (strcmp(tmp, "@") == 0)
(void)strlcpy(tmp, "", sizeof tmp);
string = tmp;
@@ -131,7 +131,7 @@
else if (!strcasecmp("dest", rtoken)) {
if (snprintf(tmp, sizeof tmp, "%s@%s",
dlv->dest.user, dlv->dest.domain) >= (int)sizeof tmp)
- return 0;
+ return -1;
if (strcmp(tmp, "@") == 0)
(void)strlcpy(tmp, "", sizeof tmp);
string = tmp;
@@ -161,17 +161,17 @@
else if (!strcasecmp("mbox.from", rtoken)) {
if (snprintf(tmp, sizeof tmp, "%s@%s",
dlv->sender.user, dlv->sender.domain) >= (int)sizeof
tmp)
- return 0;
+ return -1;
if (strcmp(tmp, "@") == 0)
(void)strlcpy(tmp, "MAILER-DAEMON", sizeof tmp);
string = tmp;
}
else
- return 0;
+ return -1;
if (string != tmp) {
if (strlcpy(tmp, string, sizeof tmp) >= sizeof tmp)
- return 0;
+ return -1;
string = tmp;
}
@@ -187,12 +187,12 @@
break;
}
if (!token_modifiers[i].f(tmp, sizeof
tmp))
- return 0; /* modifier error */
+ return -1; /* modifier error */
break;
}
}
if ((size_t)i == nitems(token_modifiers))
- return 0; /* modifier not found */
+ return -1; /* modifier not found */
} while ((mods = sep) != NULL);
}
@@ -208,7 +208,7 @@
/* begin offset beyond end of string */
if (begoff >= i)
- return 0;
+ return -1;
/* end offset beyond end of string, make it end of string */
if (endoff >= i)
@@ -225,13 +225,13 @@
/* check that final offsets are valid */
if (begoff < 0 || endoff < 0 || endoff < begoff)
- return 0;
+ return -1;
endoff += 1; /* end offset is inclusive */
/* check that substring does not exceed destination buffer length */
i = endoff - begoff;
if ((size_t)i + 1 >= len)
- return 0;
+ return -1;
string += begoff;
for (; i; i--) {
@@ -244,19 +244,19 @@
}
-size_t
+ssize_t
mda_expand_format(char *buf, size_t len, const struct deliver *dlv,
const struct userinfo *ui, const char *mda_command)
{
char tmpbuf[EXPAND_BUFFER], *ptmp, *pbuf, *ebuf;
char exptok[EXPAND_BUFFER];
- size_t exptoklen;
+ ssize_t exptoklen;
char token[MAXTOKENLEN];
size_t ret, tmpret;
if (len < sizeof tmpbuf) {
log_warnx("mda_expand_format: tmp buffer < rule buffer");
- return 0;
+ return -1;
}
memset(tmpbuf, 0, sizeof tmpbuf);
@@ -308,12 +308,12 @@
exptoklen = mda_expand_token(exptok, sizeof exptok, token, dlv,
ui, mda_command);
- if (exptoklen == 0)
- return 0;
+ if (exptoklen == -1)
+ return -1;
/* writing expanded token at ptmp will overflow tmpbuf */
- if (sizeof (tmpbuf) - (ptmp - tmpbuf) <= exptoklen)
- return 0;
+ if (sizeof (tmpbuf) - (ptmp - tmpbuf) <= (size_t)exptoklen)
+ return -1;
memcpy(ptmp, exptok, exptoklen);
pbuf = ebuf + 1;
@@ -321,10 +321,10 @@
tmpret = exptoklen;
}
if (ret >= sizeof tmpbuf)
- return 0;
+ return -1;
if ((ret = strlcpy(buf, tmpbuf, len)) >= len)
- return 0;
+ return -1;
return ret;
}
--- smtpd/smtpd.h
+++ smtpd/smtpd.h
@@ -1267,7 +1267,7 @@
/* mda_variables.c */
-size_t mda_expand_format(char *, size_t, const struct deliver *,
+ssize_t mda_expand_format(char *, size_t, const struct deliver *,
const struct userinfo *, const char *);
--
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]