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

From: EuAndreh <[email-masked]>
Date: Tue, 29 Nov 2022 18:55:41 -0300

* 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(+)

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