From: "Omar Polo" Subject: Re: smtpd: independant match and action order To: "Kirill A. Korinsky" Cc: tech@openbsd.org, Gilles Chehade Date: Sun, 01 Jun 2025 20:49:17 +0200 Kirill A. Korinsky wrote: > On Sat, 31 May 2025 18:36:41 +0200, > "Omar Polo" wrote: > > > > op@omarpolo.com wrote: > > > After an issue on github[1], I realized that we don't seem to document > > > that an action needs to be defined prior its use in a match statement. > > > > > > [1]: https://github.com/OpenSMTPD/OpenSMTPD/issues/1285 > > > > > > However, do we need this restriction? Diff belows moves the action > > > check after the configuration has been fully parsed. The downside is > > > that now you get a generic "referenced unknown action foo" error without > > > a line number, but the plus side is that action and matches can be put > > > in any order. > > > > > > The alternative would just be a man page diff to highlight the ordering > > > requirement. > > > > > > Thoughts? > > > > ping > > > > I had encountered this error but forgot to report it or dig into it. > > I not sure that define an action after match which uses it is good idea, it > smeels like a way which leads to error, and I think to make it clear in man > is the right way. I see your point, but still we can check for unknown rules (and actually we might want to warn on unreferenced actions maybe -- but that's aside from this diff) when reading a configuration usually the first thing that i read are the match rules, and only after the actions. I'm not sure, this could be the start of making the configuration parser not a first-pass one, but I'm not sure I want to push for it. For the time being, maybe we can just add one line to the manpage instead. diff /usr/src path + /usr/src commit - a8cdbfca47c492365cd5de45ff0eaa81af0849d9 blob - b2a563b4ee489834d9bcd7e5f26c1b0b1bd2c4fa file + usr.sbin/smtpd/smtpd.conf.5 --- usr.sbin/smtpd/smtpd.conf.5 +++ usr.sbin/smtpd/smtpd.conf.5 @@ -596,7 +596,10 @@ of one directive, receive the incoming message, put a copy into each matching envelope, and atomically save the envelopes to the mail spool for later processing by the respective dispatcher -.Ar name . +.Ar name +which has to be declared beforehand with the +.Ic action +directive. .Pp The following matching options are supported and can all be negated: .Bl -tag -width Ds