bug-mcron
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-mcron] [PATCH] configure: Add '--with-sendmail' for (mcron conf


From: Mathieu Lirzin
Subject: Re: [Bug-mcron] [PATCH] configure: Add '--with-sendmail' for (mcron config config-sendmail)
Date: Sun, 07 Oct 2018 11:28:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

address@hidden (宋文武) writes:

> Mathieu Lirzin <address@hidden> writes:
>
>> I am not familiar with sendmail, so can you explain why USER has been
>> removed from ‘with-mail-out’?
>
> The idea is to configure the complete command with
> '--with-sendmail=COMMAND', which avoids me a little trouble for write
> the help string (otherwise, we have to say it's partially, the final
> command will be "COMMAND USER", etc.).
>
> Considered the 'sendmail' command from opensmtpd and the 'mail' command
> from mailutils, they both can read recipients from the message header
> (with the '-t' option), So I think nothing lose here.

OK.

>> Wouldn't the ‘-t’ option better located on the caller side (meaning in
>> “src/mcron/redirect.scm”)?
>
> I think letting users configure it should be more felxible (maybe there
> is a MTA doesn't accept the '-t' option?).

Indeed, it makes sense then.

Here is an updated patch with small changes that I want to apply.
Please tell me if it's OK with you.

>From 268c8ea06adf9cf4ec7ffd150e89e13c9772744c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <address@hidden>
Date: Mon, 1 Oct 2018 14:07:48 +0800
Subject: [PATCH] build: Add '--with-sendmail' configure option

This allows users to configure the Mail Transfert Agent (MTA) of their
choice.

* configure.ac: Add '--with-sendmail' option.
(SENDMAIL): Default to 'sendmail -t'.
* NEWS: Announce it.
* src/mcron/redirect.scm (with-mail-out): Assume the MTA is reading the
message for recipients.
* build-aux/guix.scm: Remove 'which' from the native-inputs.
---
 NEWS                   |  6 ++++++
 build-aux/guix.scm     |  4 ++--
 configure.ac           | 30 ++++++++++--------------------
 src/mcron/redirect.scm |  8 ++++----
 4 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/NEWS b/NEWS
index d3f31cd..432e586 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU Mcron NEWS                                    -*- outline 
-*-
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Improvements
+
+  The "--with-sendmail" configure variable has been added to allow the usage
+  of a different Mail Transfert Agent (MTA) than 'sendmail -t'.  The MTA must
+  be able to guess the actual recipients from the 'To:' message header.
 
 * Noteworthy changes in release 1.1.1 (2018-04-08) [stable]
 
@@ -157,6 +162,7 @@ GNU Mcron NEWS                                    -*- 
outline -*-
 
 Copyright © 2003, 2005, 2006 Dale Mellor <address@hidden>
 Copyright © 2017, 2018 Mathieu Lirzin <address@hidden>
+Copyright © 2018 宋文武 <address@hidden>
 
 Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
diff --git a/build-aux/guix.scm b/build-aux/guix.scm
index d90e0be..24927ad 100644
--- a/build-aux/guix.scm
+++ b/build-aux/guix.scm
@@ -1,5 +1,6 @@
 ;;;; guix.scm -- Guix package definition
 ;;; Copyright © 2016 Mathieu Lirzin <address@hidden>
+;;; Copyright © 2018 宋文武 <address@hidden>
 ;;;
 ;;; This file is part of GNU Mcron.
 ;;;
@@ -62,5 +63,4 @@
      ("automake" ,(specification->package "automake"))
      ("help2man" ,(specification->package "help2man"))
      ("pkg-config" ,(specification->package "pkg-config"))
-     ("texinfo" ,(specification->package "texinfo"))
-     ("which" ,(specification->package "which")))))
+     ("texinfo" ,(specification->package "texinfo")))))
diff --git a/configure.ac b/configure.ac
index 0bb9262..f7e3c34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,6 +2,7 @@
 # Copyright © 2003, 2005, 2012, 2014 Dale Mellor
 # <address@hidden>
 # Copyright © 2015, 2016, 2017, 2018 Mathieu Lirzin <address@hidden>
+# Copyright © 2018 宋文武 <address@hidden>
 #
 # This file is part of GNU Mcron.
 #
@@ -55,26 +56,15 @@ GUILE_PROGS
 
 AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
 
-# Now find a sendmail or equivalent.
-
-AC_CHECK_PROGS(SENDMAIL, sendmail)
-if test "x$ac_cv_prog_SENDMAIL" != "x"; then
-   AC_MSG_CHECKING(sendmail path and arguments)
-   ac_cv_prog_SENDMAIL="`$ac_cv_prog_WHICH sendmail` -FCronDaemon -odi -oem "
-dnl  -or0s"
-   AC_MSG_RESULT($ac_cv_prog_SENDMAIL)
-
-else
-   AC_CHECK_PROGS(SENDMAIL, mail)
-   if test "x$ac_cv_prog_SENDMAIL" != "x"; then
-      AC_MSG_CHECKING(mail path)
-      ac_cv_prog_SENDMAIL="`$ac_cv_prog_WHICH mail` -d "
-      AC_MSG_RESULT($ac_cv_prog_SENDMAIL)
-   else
-      AC_MSG_RESULT(No mail program found)
-   fi
-fi
-SENDMAIL=$ac_cv_prog_SENDMAIL
+# Let users choose the Mail Transfert Agent (MTA) of their choice.  Default to
+# a non-absolute program name to make it a loose dependency resolved at
+# runtime.
+AC_ARG_WITH([sendmail],
+  [AS_HELP_STRING([--with-sendmail=COMMAND],
+    [command to read an email message from standard input, and send it])],
+  [SENDMAIL="$withval"],
+  [SENDMAIL="sendmail -t"])
+AC_SUBST([SENDMAIL])
 
 AC_ARG_ENABLE([multi-user],
   [AS_HELP_STRING([--disable-multi-user],
diff --git a/src/mcron/redirect.scm b/src/mcron/redirect.scm
index 6711407..b7df42c 100644
--- a/src/mcron/redirect.scm
+++ b/src/mcron/redirect.scm
@@ -1,5 +1,6 @@
 ;;;; redirect.scm -- modify job outputs
 ;;; Copyright © 2003 Dale Mellor <address@hidden>
+;;; Copyright © 2018 宋文武 <address@hidden>
 ;;;
 ;;; This file is part of GNU Mcron.
 ;;;
@@ -170,10 +171,9 @@
           (set-current-output-port (if (and (string? mailto)
                                             (string=? mailto ""))
                                        (open-output-file "/dev/null")
-                                       (open-output-pipe
-                                          (string-append config-sendmail
-                                                         " "
-                                                         user))))
+                                       ;; The sendmail command should read
+                                       ;; recipients from the message header.
+                                       (open-output-pipe config-sendmail)))
           (set-current-input-port (car child->parent))
           (display "To: ") (display user) (newline)
           (display "From: mcron") (newline)
-- 
2.19.1

Thanks.

-- 
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

reply via email to

[Prev in Thread] Current Thread [Next in Thread]