Subject: Re: Queued messages in OpenSMTPd

From: Tomas Volf <[email-masked]>
Date: Wed, 15 Jan 2025 17:21:59 +0100

Felix Lechner <[email-masked]> writes:

> Hi Tomas,
>
> Okay, maybe your patch is the right way but, aside from adding makemap,
> is it all that superior?

Well the reason I even wrote this patch is that (at least for me) the
original fix no longer works.

Notice the path in the following snippet (the commit is current HEAD at
the time of writing this):

--8<---------------cut here---------------start------------->8---
$ strings $(guix time-machine -q --commit=b696658ee8e0655b17f5d26e024956b5148e36d6 -- build opensmtpd)/sbin/smtpd | grep smtpctl
/gnu/store/7p98k2p2d3zza41sv1npy3y90c280grc-opensmtpd-7.6.0p1/sbin/smtpctl
warn: smtpd: couldn't enqueue offline message %s; smtpctl %s
--8<---------------cut here---------------end--------------->8---

As you can see, it points into the store.

During debugging I noticed two issues:

1. The path in smtpd.h[0] is /usr/sbin/smtpctl, but the code looks for
/usr/bin/smtpctl (sbin vs bin).

2. The #define is guarded by #ifndef[1], so even if the path is
replaced, it is never used (due to [2]).

After my fix, the binary now contains the correct path:

--8<---------------cut here---------------start------------->8---
$ strings $(guix build opensmtpd)/sbin/smtpd | grep smtpctl
/run/privileged/bin/smtpctl
warn: smtpd: couldn't enqueue offline message %s; smtpctl %s
--8<---------------cut here---------------end--------------->8---

Does the current version work for you?  I do not think I am doing
anything weird in my configuration, but I was not able to pinpoint any
upstream change that would have effect on this, so I am unsure why the
original version stopped working.

Have a nice day,
Tomas

0: https://github.com/OpenSMTPD/OpenSMTPD/blob/master/usr.sbin/smtpd/smtpd.h#L81
1: https://github.com/OpenSMTPD/OpenSMTPD/blob/master/usr.sbin/smtpd/smtpd.h#L80
2: https://github.com/OpenSMTPD/OpenSMTPD/blob/master/mk/pathnames#L7

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.