Subject: Re: [bug#59701] [PATCH] gnu: mailutils: Inform correct path of sendmail.

From: EuAndreh <[email-masked]>
Date: Thu, 1 Dec 2022 10:15:55 +0000

Come to think of it, I did try it.  It required a significant amount of 
patches to the source code itself, to the point where one should prepare 
a patchset and send upstream, after refactoring some of the code.

The problem is that the aforementioned search path used is searched at 
compile-time, and if no sendmail binary is found, the absolute fallback 
path is used instead.  So instead of a run-time $PATH lookup, it has a 
compile-time /usr/sbin:/usr/lib:/etc lookup, with a /usr/sbin/sendmail 
fallback.

Ideally we would like to have:

1. not looking for sendmail binaries at compile-time, and relying on 
$PATH instead;
2. not having a fallback absolute path to a fallback binary, and just 
get a ENOENT at runtime instead, plus a few more diagnostic messages to 
STDERR.

As I progressed in achieving that, I had modification on top of 
modification to the build system and the source code, and at some point 
I found myself questioning the approach, as it was becoming too fragile 
and too custom.

There is no bug registered in GNU Mailutils' bug database, but there is 
a thread [0] in its list with people talking about when the exact same 
problem was encountered when our friends at Nix packaged mailutils [1].

The suggestion [2] from the maintainer is actually to put a symlink to 
the setuid sendmail binary where mailutils expects to find it:

 > There's no way to do this currently, except for symlinking the actual
 > sendmail-compatible binary (whatever it is in your distro) to the
 > predefined path (preferably, to the place defined by _PATH_SENDMAIL
 > in your /usr/include/paths.h). In fact, that's what all distros that
 > I've ever seen do.

The difference for Guix (and Nix) is that /usr/sbin/ doesn't even exist, 
so we use the PATH_SENDMAIL macro to tell mailutils where to find 
sendmail, as upstream seems happy with the state of affairs.

[0]: https://lists.gnu.org/archive/html/bug-mailutils/2017-10/msg00004.html
[1]: https://github.com/NixOS/nixpkgs/issues/21008
[2]: https://lists.gnu.org/archive/html/bug-mailutils/2017-10/msg00001.html