[PATCH] gnu: mailutils: Inform correct path of sendmail.

  • Open
  • quality assurance status badge
Details
5 participants
  • Efraim Flashner
  • EuAndreh
  • ???
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
EuAndreh
Severity
normal
E
E
EuAndreh wrote on 29 Nov 2022 22:55
(address . guix-patches@gnu.org)(name . EuAndreh)(address . eu@euandre.org)
20221129215541.26224-1-eu@euandre.org
* gnu/packages/mail.scm (mailutils)[arguments]: Add -DPATH_SENDMAIL
to CFLAGS pointing to /run/setuid-programs.
---

Notes:
The current compilation options of GNU Mailutils don't specify a value
for the "PATH_SENDMAIL" C macro. The build system of the package looks
for a definition of this variable in the "paths.h" header file from the
glibc package, and falls back to what is defined as the default in its
"paths" file, /usr/sbin/sendmail.
As this binary doesn't exist, "mail" fails to execute:
$ cat mail.txt
From: root
To: root
Subject: This fails
The body
$ mail -t < mail.txt
mail: Cannot open mailer: No such file or directory
mail: cannot send message: No such file or directory
$ echo $?
1
I've confirmed this by looking at the file called "paths" in the source
code of mailutils, and at the strace output of calling mailutils. I
do have a working sendmail binary under /run/setuid-programs, and it
now it is correctly called by the "mail" command, from mailutils.
Given that this was the default, probably most Guix users do have a
/root/dead.letter, with emails from the system, mainly rottlog
notifications of log rotations, as it does use GNU Mailutils directly in
its /etc/rottlog/rc configuration.

gnu/packages/mail.scm | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (16 lines)
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index cef5fe2916..2c42cdfaca 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -347,6 +347,9 @@ (define-public mailutils
#~(list "--sysconfdir=/etc"
"--disable-static"
+ ;; Specify path to sendmail setuid binary, which otherwise
+ ;; defaults to /usr/sbin/sendmail
+ "CFLAGS=-DPATH_SENDMAIL=\\\"/run/setuid-programs\\\""
;; Add "/X.Y" to the installation directory.
(string-append "--with-guile-site-dir="
(assoc-ref %outputs "out")
--
2.38.1
E
E
EuAndreh wrote on 29 Nov 2022 22:57
[PATCH v2] gnu: mailutils: Inform correct path of sendmail.
(address . 59701@debbugs.gnu.org)(name . EuAndreh)(address . eu@euandre.org)
20221129215721.14591-1-eu@euandre.org
* gnu/packages/mail.scm (mailutils)[arguments]: Add -DPATH_SENDMAIL
to CFLAGS pointing to /run/setuid-programs.
---
Oops, now with the correct path.

gnu/packages/mail.scm | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (16 lines)
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index cef5fe2916..754c9bc6de 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -347,6 +347,9 @@ (define-public mailutils
#~(list "--sysconfdir=/etc"
"--disable-static"
+ ;; Specify path to sendmail setuid binary, which otherwise
+ ;; defaults to /usr/sbin/sendmail
+ "CFLAGS=-DPATH_SENDMAIL=\\\"/run/setuid-programs/sendmail\\\""
;; Add "/X.Y" to the installation directory.
(string-append "--with-guile-site-dir="
(assoc-ref %outputs "out")
--
2.38.1
T
T
Tobias Geerinckx-Rice wrote on 29 Nov 2022 23:11
Re: [bug#59701] [PATCH] gnu: mailutils: Inform correct path of sendmail.
(name . EuAndreh)(address . eu@euandre.org)
87o7spe7do.fsf@nckx
EuAndreh via Guix-patches via ???
Toggle quote (4 lines)
> * gnu/packages/mail.scm (mailutils)[arguments]: Add
> -DPATH_SENDMAIL
> to CFLAGS pointing to /run/setuid-programs.

Thanks!

Did you try making mailutils simply respect $PATH instead? Do you
know why it doesn't? Can't?

Hard-coding a distribution-specific location is something we often
bemoan other packages doing…

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCY4aEJA0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW158WAA/iiEV8BEXJJw6p6cWLa4WOuXvFMWsiWVIBg88DJi
9TLkAQCozXoN220qPbeNEXD/sC+4gavFIcttx89sH8vXTpkPCA==
=v9na
-----END PGP SIGNATURE-----

E
E
EuAndreh wrote on 29 Nov 2022 23:31
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
a80d748a-7e96-822b-b501-9c05c7637f02@euandre.org
I did try it, but it was mailutils that I feel forced my hand. It uses
a pre-defined list of paths to search, instead of $PATH, namely:

/usr/sbin:/usr/lib:/etc

So I feel the opposite ocurred: I wanted it to just rely on $PATH, but
mailutils used a specific search path, but it at least gives us a way in
to put a custom value.
E
E
EuAndreh wrote on 29 Nov 2022 23:33
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
06a02b6f-5dcc-0686-95d0-f6e1b274d466@euandre.org
This is the *compile-time* search path used by the build system, no the
runtime one.
E
E
Efraim Flashner wrote on 1 Dec 2022 09:26
(name . EuAndreh)(address . eu@euandre.org)
Y4hlLh4Vdyyx4Nsp@3900XT
On Tue, Nov 29, 2022 at 10:31:33PM +0000, EuAndreh via Guix-patches via wrote:
Toggle quote (9 lines)
> I did try it, but it was mailutils that I feel forced my hand. It uses a
> pre-defined list of paths to search, instead of $PATH, namely:
>
> /usr/sbin:/usr/lib:/etc
>
> So I feel the opposite ocurred: I wanted it to just rely on $PATH, but
> mailutils used a specific search path, but it at least gives us a way in to
> put a custom value.

Can we change that value to $PATH? I checked and I don't have sendmail
in /run/setuid-programs, and I know I'd use my msmtp setup for sendmail
*for myself* but not for the system if it were available.

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmOIZS4ACgkQQarn3Mo9
g1H2YxAAnK/O9SWU2fg7FwXxZx+ppRO/ZyEoivW4HyNrAAZDRiPLxygGHZTtHEqx
wBQ+Nfm1jzqXfJHGx2vHCRyFBfv8mDs0dzct1ieTvuNHp162wzG4cU+QML/FeT4M
aDkrzVP4kSvB0Fz5OeCYZEBYSEwUwNRd7Js7QgbTCOdQqHlgfAzcJeEt8lUstH5r
H6AZpEIR1/Pdf+NVJRCkY9DIKc8UDVmmZT+SOLQ0MigTEzt5wDBodtQFKAHKHNXp
VJKuyEsVD57zJzvRzZg+ufl4nnTHvr4LAEEddt7MkrCj2S1RBj3RF5D4V/UaXR7u
vT1IdSDaW/tV6PSHxds48DI7LMyP+8NmhH3H4Eoho23O9G/q4Tpns4fhA14d9mnq
+gcvLSUhYWlAXoASEcue9TIjUgWchC14yUguI0A3EB4cCFAfqurWyrcqhFdAqEHh
DI5YixdzKw1wOj+NGVkjUECw5y3pkWxuGJ27RA+xVtlQdplEa205HDpKYhqqrOVA
QQOWyVKYhpRYU4u5p76NIeD7m6FBKcBQGCVMF6SVBepiD/wFBGfmVaQtpEEIsz1Y
y6w4oaB2j7466UIsO4BYrmB4pfiz6dme9I6c9Xa5C4w24SUta2gmxRsRTfe1dbFa
g5cKEnUF9pocM7nhwD3DDhDIzpB5BazVh7JkMVl4fKd1g0LIcEA=
=16iH
-----END PGP SIGNATURE-----


E
E
EuAndreh wrote on 1 Dec 2022 11:30
(address . guix-patches@gnu.org)
f0f5a885-f9b9-1072-bf67-3560a1d804c4@euandre.org
Toggle quote (4 lines)
> Can we change that value to $PATH? I checked and I don't have sendmail
> in /run/setuid-programs, and I know I'd use my msmtp setup for sendmail
> *for myself* but not for the system if it were available.

With mailutils, I'm afraid this can't be done.

What our Nix friends do is have a module (which is equivalent to a Guix
service) that accepts a "setSendmail" option [0] which, when true, adds
the a setuid msmtp binary wrapper [1].

That mixes up user-level and system-level configuration, and the only
way around is add a user-level alias wrapper for mailutils wrapper that
specifies where to find sendmail at runtime:

alias mail="mail -E'set
sendmail=\"$HOME/.guix-home/profile/bin/msmtp\"'"

Doing this to the mailutils package definition would require juggling
some options around and knowing very well how mailutils handles options,
so that the dynamic lookup of the sendmail binary doesn't break anything
else.

[0]:
[1]:
E
E
EuAndreh wrote on 1 Dec 2022 10:40
fca4318b-399a-6670-9ff4-1cf4fa62ba3f@euandre.org
That's a good idea. Let me try it.
E
E
EuAndreh wrote on 1 Dec 2022 11:15
a8582985-9354-0218-9404-d112036afa61@euandre.org
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.


T
T
Tobias Geerinckx-Rice wrote on 1 Dec 2022 15:19
(name . EuAndreh)(address . eu@euandre.org)
87wn7bxl1g.fsf@nckx
EuAndreh ???
Toggle quote (5 lines)
> I did try it, but it was mailutils that I feel forced my hand.
> It
> uses a pre-defined list of paths to search, instead of $PATH,
> namely:

Thanks, but I think you missed my point. I suggested *making* it
respect $PATH.

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCY4i4PA0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15CMUA/3QbcKbvkXScx2PAAqEEs1tSmfaaBdnjPyoc6uMJ
UsAXAQDI8t3JhXxpvZ1AjfJcPVyK4nChMh7cc2j7qgXbEB9rDw==
=wP+Q
-----END PGP SIGNATURE-----

E
E
EuAndreh wrote on 1 Dec 2022 16:25
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 59701@debbugs.gnu.org)
1ee39412-92ce-3940-682a-56d4ca9063b6@euandre.org
From what I could read and debug from the mailutils source code, this
would require a non-trivial amount of refactoring, not a couple of
(substitute* ...) calls some a few files.

This should be done by submitting changes upstream, so that the
maintainer can properly review and apply them. I'd say this is how this
software is written to work right now, and tweaking it would be
thwarting its core purpose.
?
Re: bug#59701: [PATCH] gnu: mailutils: Inform correct path of sendmail.
(name . EuAndreh)(address . eu@euandre.org)(address . 59701@debbugs.gnu.org)
87k02vizhn.fsf_-_@envs.net
EuAndreh <eu@euandre.org> writes:

Toggle quote (6 lines)
>> Can we change that value to $PATH? I checked and I don't have sendmail
>> in /run/setuid-programs, and I know I'd use my msmtp setup for sendmail
>> *for myself* but not for the system if it were available.
>
> With mailutils, I'm afraid this can't be done.

For the `mail` command, it can be customized in a `~/.mailrc` file, maybe:
```
set sendmail=sendmail:/run/setuid-programs/sendmail
# or set sendmail=smtp://127.0.0.1
```
L
L
Ludovic Courtès wrote on 14 Dec 2022 12:03
control message for bug #59701
(address . control@debbugs.gnu.org)
87ilietfgj.fsf@gnu.org
tags 59701 + moreinfo
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 59701@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 59701
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch