Source: opensmtpd-extras
Version: 5.7.1-3
The filter API versions present in the opensmtpd and opensmtpd-extras source
packages do not match. This causes a critical error in opensmtpd when using
a filter from the opensmtpd-extras-experimental package which prevents the
smtpd from starting.
This behaviour was observed when trying to configure my opensmtpd installation
to use the "pause" filter. I had the following configuration lines in my
/etc/smtpd.conf:
filter pause pause
<snip>
listen on eth0 port 25 tls pki [domain elided] filter pause
opensmtpd reports the configuration file is valid.
$ sudo smtpd -n
configuration OK
However, when I attempted to start opensmtpd either through `systemctl start
opensmtpd` or on the command line, no smtpd processes are present in the
process tree. In /var/log/mail.info I saw the following lines:
smtpd[17362]: info: OpenSMTPD 6.0.2p1 starting
smtpd[17365]: setup_peer: control -> klondike[17364] fd=8
smtpd[17365]: setup_peer: control -> lookup[17366] fd=9
smtpd[17369]: setup_peer: scheduler -> control[17365] fd=12
smtpd[17369]: setup_peer: scheduler -> queue[17368] fd=13
smtpd[17367]: setup_peer: pony express -> control[17365] fd=10
smtpd[17367]: setup_peer: pony express -> klondike[17364] fd=11
smtpd[17367]: setup_peer: pony express -> lookup[17366] fd=12
smtpd[17367]: setup_peer: pony express -> queue[17368] fd=13
smtpd[17365]: setup_peer: control -> pony express[17367] fd=10
smtpd[17365]: setup_peer: control -> queue[17368] fd=11
smtpd[17365]: setup_peer: control -> scheduler[17369] fd=12
smtpd[17366]: setup_peer: lookup -> control[17365] fd=9
smtpd[17366]: setup_peer: lookup -> pony express[17367] fd=10
smtpd[17366]: setup_peer: lookup -> queue[17368] fd=11
smtpd[17368]: setup_peer: queue -> control[17365] fd=11
smtpd[17368]: setup_peer: queue -> pony express[17367] fd=12
smtpd[17368]: setup_peer: queue -> lookup[17366] fd=13
smtpd[17368]: setup_peer: queue -> scheduler[17369] fd=14
smtpd[17364]: setup_peer: klondike -> control[17365] fd=7
smtpd[17364]: setup_peer: klondike -> pony express[17367] fd=8
smtpd[17364]: setup_proc: klondike done
smtpd[17363]: setup_done: ca[17364] done
smtpd[17365]: setup_proc: control done
smtpd[17363]: setup_done: control[17365] done
smtpd[17363]: setup_done: lka[17366] done
smtpd[17367]: setup_proc: pony express done
smtpd[17363]: setup_done: pony[17367] done
smtpd[17366]: setup_proc: lookup done
smtpd[17363]: setup_done: queue[17368] done
smtpd[17369]: setup_proc: scheduler done
smtpd[17363]: setup_done: scheduler[17369] done
smtpd[17363]: smtpd: setup done
smtpd[17368]: setup_proc: queue done
smtpd[17367]: warn: pony -> pause: pipe closed
smtpd[17367]: warn: filter "pause" closed unexpectedly
smtpd[17367]: fatal: exiting
smtpd[17365]: warn: control -> pony express: pipe closed
smtpd[17364]: warn: ca -> pony express: pipe closed
smtpd[17363]: warn: parent -> pony: pipe closed
smtpd[17369]: warn: scheduler -> control: pipe closed
smtpd[17368]: warn: queue -> pony express: pipe closed
smtpd[17366]: warn: lka -> control: pipe closed
I then attempted to run opensmtpd on the command line ('-d' switch) with
verbose logging enabled ('-v' switch). In the produced output the following
lines were present:
pause: invalid option -- 'v'
warn: filter-pause: bad option
I also ran opensmtpd under strace and searched the output for "pause", the
name I had configured the filter with (some output elided for brevity):
$ sudo strace -s256 -vf smtpd 2>&1 | grep pause
[pid 17550] execve("/usr/lib/x86_64-linux-gnu/opensmtpd/filter-pause",
["pause"], [<environment variables>] <unfinished ...>
[pid 17547] sendmsg(23, { <sendmsg data> }, 0) = 28
[pid 17550] <... recvmsg resumed> { <recvmsg data> }, 0) = 28
[pid 17550] write(2, "warn: filter-api:pause API mismatch\n", 36
<unfinished ...>
[pid 17547] sendto(9, "<18>Aug 30 11:38:01 smtpd[17547]: warn: pony ->
pause: pipe closed", 66, MSG_NOSIGNAL, NULL, 0 <unfinished ...>
[pid 17547] sendto(9, "<18>Aug 30 11:38:01 smtpd[17547]: warn: filter
\"pause\" closed unexpectedly", 74, MSG_NOSIGNAL, NULL, 0) = 74
The data in write() syscall above in the strace output says that the filter
is using a different IPC API version from the smtpd. To confirm this, I
downloaded the source packages of opensmtpd and opensmtpd-extras and inspected
the source code. The API version in opensmtpd is defined in the file
smtpd/smtpd-api.h:
#define FILTER_API_VERSION 51
The API version in opensmtpd-extras is defined in the file api/smtpd-api.h:
#define FILTER_API_VERSION 50
I also compared the source of the "pause" filter in the opensmtpd-extras
source package and the most recent version in the upstream opensmtpd-extras
repository on GitHub (https://github.com/OpenSMTPD/OpenSMTPD-extras), which
is currently under the "filter-pause" branch. The getopt() loop from the
older version shipped with Debian does not handle the '-v' or '-d' flags,
which are passed from smtpd under the newer API when smtpd has been provided
with those flags itself.
The most recent version of the filter-pause program does function correctly
with the packaged version of opensmtpd. I downloaded and compiled the source
from the upstream GitHub repository and installed the newer filter-pause as
filter-newpause. I adjusted /etc/smtpd.conf and successfully managed to start
smtpd with the "newpause" filter.
There are a few options available for resolving this bug as far as I am aware.
The first is to backport the API changes onto the current Debian
opensmtpd-extras package, however this is likely a non-trivial amount of
work relative to the (presumably small) number of Debian users using OpenSMTPD.
The other option is to upgrade the opensmtpd-extras source package to one of
the more recent versions listed here: https:///opensmtpd.org/archives/ .
There are only three versions which have the same API version as the current
opensmtpd source package: the 05/07/2016, 06/07/2016, and 12/07/2016 versions.
It should also be noted that the upstream decided in early July last year to
remove filter programs they deem to be "experimental" into their own branches
in the git repository and remove them from the default distribution (git commit
hash 39799183929). This includes some filters shipped by Debian in the
opensmtpd-extras-experimental package; future versions of that package will
either break existing installations which rely on the experimental filters or
will have to import them from their branches in the upstream repository.
Bug observed on Debian 9.1, kernel version 4.9.20-std-1 (provided by hosting
provider), libc6 version 2.24-11+deb9u1.