Hello!
I'm trying to migrate my server from Ubuntu Linux to FreeBSD. On Linux I was using Postfix with OpenDKIM to sign outgoing e-mails, but I'm interested to try OpenSMTPD on FreeBSD due to easier configuration syntax. Getting OpenSMTPD running with Dovecot was quite a breeze - I can receive and send e-mails without a problem, but I also want to add DKIM signing for outgoing e-mails (and optionally verification for incoming e-mails). After some googling it seems that de facto standard is to use OpenSMTPD with Rspamd. I don't care so much about filtering for spam for now since its volume has been low for years and I'm actually baffled that Rspamd is used for DKIM signing. I can justify a little that Rspamd uses DKIM verification for incoming e-mails, but why should it touch outgoing e-mails at all? Anyway, I was looking for some alternative solutions where I could use UNIX approach where I can use a tool, which does one thing and does it well and found one blog post where similar thoughts have been written (https://palant.info/2020/11/09/adding-dkim-support-to-opensmtpd-with-custom-filters/). Basically through that blog post it's possible to acquire 3 Python scripts to make DKIM verification and signing possible. I've had some issues with Python, but managed to make it work in the end - I can send properly DKIM signed e-mails and verify incoming DKIM signatures. However, I'm not too happy with using Python scripts written by some random guy in the internet for that and was hoping to find something more mature and found that there is a site hosting source code for filter-dkimsign (https://imperialat.at/dev/filter-dkimsign/) and filter-dkimverify (https://imperialat.at/dev/filter-dkimverify/). As I understand then this code has been written by one of the OpenBSD developers (I might be wrong of course). But nevertheless, for some reason these filters do not exist as a port nor FreeBSD package. I've also found via Google that they did exist as ports at one time, but I don't know why were they removed (if anyone knows, then that might be helpful too - was there some important reason for removal?). However, these packages seem to exist for some Linux distros, so I guess it has to work? Problem is that I didn't find any instructions/blog articles about compiling these filters on FreeBSD and I'm not too proficient with C.
Anyway, I wanted to try these filters instead of running a Python interpreter for DKIM signing/verification, but I'm failing to compile these.
Here's what I tried so far:
This failed with the following error:
I hoped that I already have opensmtpd.h somewhere in the system (OpenSMTPD was installed via pkg install), but did not find it under /usr/local/include. Now I noticed that there is libopensmtpd (http://imperialat.at/dev/libopensmtpd/) with this header file so I downloaded this too and tried to compile it, but failed too:
This is the error now:
Not sure what event.h is even needed, but I see one at /usr/local/include/event.h so I suspect that this might be it. However, for some reason Makefile under libopensmtpd does not include headers under /usr/local/include (in contrast, filter-dkimsign does that). I even modified Makefile by adding the following line:
But it didn't help with the compilation, which fails in the following way:
Any ideas how to compile these filters on FreeBSD? Has anyone done that or is there a real reason why not to do that and why I should also use Rspamd for DKIM as everyone else seem to be doing or just keep using these filters written in Python?
I'm running FreeBSD 13.2-RELEASE.
I'm trying to migrate my server from Ubuntu Linux to FreeBSD. On Linux I was using Postfix with OpenDKIM to sign outgoing e-mails, but I'm interested to try OpenSMTPD on FreeBSD due to easier configuration syntax. Getting OpenSMTPD running with Dovecot was quite a breeze - I can receive and send e-mails without a problem, but I also want to add DKIM signing for outgoing e-mails (and optionally verification for incoming e-mails). After some googling it seems that de facto standard is to use OpenSMTPD with Rspamd. I don't care so much about filtering for spam for now since its volume has been low for years and I'm actually baffled that Rspamd is used for DKIM signing. I can justify a little that Rspamd uses DKIM verification for incoming e-mails, but why should it touch outgoing e-mails at all? Anyway, I was looking for some alternative solutions where I could use UNIX approach where I can use a tool, which does one thing and does it well and found one blog post where similar thoughts have been written (https://palant.info/2020/11/09/adding-dkim-support-to-opensmtpd-with-custom-filters/). Basically through that blog post it's possible to acquire 3 Python scripts to make DKIM verification and signing possible. I've had some issues with Python, but managed to make it work in the end - I can send properly DKIM signed e-mails and verify incoming DKIM signatures. However, I'm not too happy with using Python scripts written by some random guy in the internet for that and was hoping to find something more mature and found that there is a site hosting source code for filter-dkimsign (https://imperialat.at/dev/filter-dkimsign/) and filter-dkimverify (https://imperialat.at/dev/filter-dkimverify/). As I understand then this code has been written by one of the OpenBSD developers (I might be wrong of course). But nevertheless, for some reason these filters do not exist as a port nor FreeBSD package. I've also found via Google that they did exist as ports at one time, but I don't know why were they removed (if anyone knows, then that might be helpful too - was there some important reason for removal?). However, these packages seem to exist for some Linux distros, so I guess it has to work? Problem is that I didn't find any instructions/blog articles about compiling these filters on FreeBSD and I'm not too proficient with C.
Anyway, I wanted to try these filters instead of running a Python interpreter for DKIM signing/verification, but I'm failing to compile these.
Here's what I tried so far:
Bash:
wget --no-parent -r https://imperialat.at/dev/filter-dkimsign/
cd imperialat.at/dev/filter-dkimsign
make
This failed with the following error:
Bash:
main.c:32:10: fatal error: 'opensmtpd.h' file not found
I hoped that I already have opensmtpd.h somewhere in the system (OpenSMTPD was installed via pkg install), but did not find it under /usr/local/include. Now I noticed that there is libopensmtpd (http://imperialat.at/dev/libopensmtpd/) with this header file so I downloaded this too and tried to compile it, but failed too:
Bash:
wget --no-parent -r https://imperialat.at/dev/libopensmtpd/
cd imperialat.at/dev/libopensmtpd
make
This is the error now:
Bash:
opensmtpd.c:27:10: fatal error: 'event.h' file not found
Not sure what event.h is even needed, but I see one at /usr/local/include/event.h so I suspect that this might be it. However, for some reason Makefile under libopensmtpd does not include headers under /usr/local/include (in contrast, filter-dkimsign does that). I even modified Makefile by adding the following line:
Bash:
CFLAGS+= -I${LOCALBASE}/include
But it didn't help with the compilation, which fails in the following way:
Bash:
ioev.c:757:29: error: invalid application of 'sizeof' to an incomplete type 'struct sockaddr_in6'
if (bsa && bind(sock, bsa, SA_LEN(bsa)) == -1)
^~~~~~~~~~~
libopensmtpd/ioev.h:35:25: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in6) : \
^ ~~~~~~~~~~~~~~~~~~~~~
ioev.c:757:29: note: forward declaration of 'struct sockaddr_in6'
libopensmtpd/ioev.h:35:39: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in6) : \
^
ioev.c:757:29: error: invalid application of 'sizeof' to an incomplete type 'struct sockaddr_in'
if (bsa && bind(sock, bsa, SA_LEN(bsa)) == -1)
^~~~~~~~~~~
libopensmtpd/ioev.h:36:25: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in))
^ ~~~~~~~~~~~~~~~~~~~~
ioev.c:757:29: note: forward declaration of 'struct sockaddr_in'
libopensmtpd/ioev.h:36:39: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in))
^
ioev.c:760:24: error: invalid application of 'sizeof' to an incomplete type 'struct sockaddr_in6'
if (connect(sock, sa, SA_LEN(sa)) == -1)
^~~~~~~~~~
libopensmtpd/ioev.h:35:25: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in6) : \
^ ~~~~~~~~~~~~~~~~~~~~~
ioev.c:760:24: note: forward declaration of 'struct sockaddr_in6'
libopensmtpd/ioev.h:35:39: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in6) : \
^
ioev.c:760:24: error: invalid application of 'sizeof' to an incomplete type 'struct sockaddr_in'
if (connect(sock, sa, SA_LEN(sa)) == -1)
^~~~~~~~~~
libopensmtpd/ioev.h:36:25: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in))
^ ~~~~~~~~~~~~~~~~~~~~
ioev.c:760:24: note: forward declaration of 'struct sockaddr_in'
libopensmtpd/ioev.h:36:39: note: expanded from macro 'SA_LEN'
sizeof(struct sockaddr_in))
Any ideas how to compile these filters on FreeBSD? Has anyone done that or is there a real reason why not to do that and why I should also use Rspamd for DKIM as everyone else seem to be doing or just keep using these filters written in Python?
I'm running FreeBSD 13.2-RELEASE.