Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Mar 2008 09:36:24 +0300
From:      "Mike Telahun Makonnen" <mtm@FreeBSD.Org>
To:        "Gregory Shapiro" <gshapiro@freebsd.org>
Cc:        Giorgos Keramidas <keramida@ceid.upatras.gr>, current@freebsd.org
Subject:   Re: latest rc.subr breaks etc/rc.d/sendmail
Message-ID:  <584bfc3f0803122336r96f4033pc0e25a7324fb0486@mail.gmail.com>
In-Reply-To: <20080311025333.GF2422@monkeyboy.local>
References:  <20080202012707.GA1800@kobe.laptop> <1204809780.885.3.camel@sol> <20080306201905.GA11317@kobe.laptop> <20080311025333.GF2422@monkeyboy.local>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Tue, Mar 11, 2008 at 5:53 AM, Gregory Shapiro <gshapiro@freebsd.org> wrote:
> > Agreed.  We should probably consult gshapiro about this, and just do it
>  > if there's no objection.  AFAIK, /etc/rc.d/sendmail is also used to
>  > start alternative MTAs, so we can commit this patch for now, and think
>  > about splitting /etc/rc.d/sendmail to something like:
>  >
>  >    src/etc/rc.d/sendmail
>  >    src/etc/rc.d/sendmail-submit
>  >    src/etc/rc.d/sendmail-outbound
>  >    src/etc/rc.d/sendmail-msp-queue
>
>  I'd be cool with this and more than happy to provide code review.
>  The four scripts would all need the same sort of logic to disable
>  conflicting options (e.g., don't start a submit agent if a full MTA is
>  running).

Can yoiu take a look at the following patch please? It splits out
rc.d/sendmail into its constituent parts. I've split out the logic to
sort out conflicting options and rebuild the aliases database into a
separate file in /etc/mail/sendmail.subr. The rc.d scripts simply call
the appropriate routines in this file. In addition I've kept
rc.d/sendmail but added the nostart keyword.

Cheers.

Mike.

[-- Attachment #2 --]
Index: etc/mail/sendmail.subr
===================================================================
RCS file: etc/mail/sendmail.subr
diff -N etc/mail/sendmail.subr
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/mail/sendmail.subr	12 Mar 2008 18:34:26 -0000
@@ -0,0 +1,53 @@
+# $FreeBSD$
+#
+# This file contains common subroutines used by sendmail(1) scripts
+# in rc.d
+#
+
+# adjust_sendmail_knobs
+#	Adjusts what sendmail knobs to turn off depending on the values of
+#	the various knobs.
+#
+adjust_sendmail_knobs()
+{
+	case ${sendmail_enable} in
+	[Nn][Oo][Nn][Ee])
+		sendmail_enable="NO"
+		sendmail_submit_enable="NO"
+		sendmail_outbound_enable="NO"
+		sendmail_msp_queue_enable="NO"
+		;;
+	esac
+
+	# If sendmail_enable=yes, don't need submit or outbound daemon
+	if checkyesno sendmail_enable; then
+		sendmail_submit_enable="NO"
+		sendmail_outbound_enable="NO"
+	fi
+
+	# If sendmail_submit_enable=yes, don't need outbound daemon
+	if checkyesno sendmail_submit_enable; then
+		sendmail_outbound_enable="NO"
+	fi
+}
+
+# rebuild aliases
+#	Rebuilds the the aliases database.
+#
+rebuild_aliases()
+{
+	# check modifications on /etc/mail/aliases
+	if checkyesno sendmail_rebuild_aliases; then
+		if [ -f "/etc/mail/aliases.db" ]; then
+			if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
+				echo \
+	    	"${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
+				/usr/bin/newaliases
+			fi
+		else
+			echo \
+	    	"${name}: /etc/mail/aliases.db not present, generating"
+				/usr/bin/newaliases
+		fi
+	fi
+}
Index: etc/rc.d/sendmail
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/sendmail,v
retrieving revision 1.18
diff -u -r1.18 sendmail
--- etc/rc.d/sendmail	8 Dec 2007 07:20:22 -0000	1.18
+++ etc/rc.d/sendmail	12 Mar 2008 18:44:25 -0000
@@ -5,13 +5,13 @@
 
 # PROVIDE: mail
 # REQUIRE: LOGIN cleanvar
+# KEYWORDS: nostart
+#
 #	we make mail start late, so that things like .forward's are not
 #	processed until the system is fully operational
 
-# XXX - Get together with sendmail mantainer to figure out how to
-#	better handle SENDMAIL_ENABLE and 3rd party MTAs.
-#
 . /etc/rc.subr
+. /etc/mail/sendmail.subr
 
 name="sendmail"
 rcvar=`set_rcvar`
@@ -23,26 +23,6 @@
 pidfile=${sendmail_pidfile:-/var/run/${name}.pid}
 procname=${sendmail_procname:-/usr/sbin/${name}}
 
-case ${sendmail_enable} in
-[Nn][Oo][Nn][Ee])
-	sendmail_enable="NO"
-	sendmail_submit_enable="NO"
-	sendmail_outbound_enable="NO"
-	sendmail_msp_queue_enable="NO"
-	;;
-esac
-
-# If sendmail_enable=yes, don't need submit or outbound daemon
-if checkyesno sendmail_enable; then
-	sendmail_submit_enable="NO"
-	sendmail_outbound_enable="NO"
-fi
-
-# If sendmail_submit_enable=yes, don't need outbound daemon
-if checkyesno sendmail_submit_enable; then
-	sendmail_outbound_enable="NO"
-fi
-
 sendmail_precmd()
 {
 	# Die if there's pre-8.10 custom configuration file.  This check is
@@ -56,43 +36,20 @@
 		fi
 	fi
 
-	# check modifications on /etc/mail/aliases
-	if checkyesno sendmail_rebuild_aliases; then
-		if [ -f "/etc/mail/aliases.db" ]; then
-			if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
-				echo \
-	    	"${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
-				/usr/bin/newaliases
-			fi
-		else
-			echo \
-	    	"${name}: /etc/mail/aliases.db not present, generating"
-				/usr/bin/newaliases
-		fi
-	fi
+	rebuild_aliases
 }
 
-run_rc_command "$1"
+# Pre-cook sendmail related knobs before continuing.
+adjust_sendmail_knobs
 
-required_files=
+run_rc_command "$1"
 
 if checkyesno sendmail_submit_enable; then
-	name="sendmail_submit"
-	rcvar=`set_rcvar`
-	start_cmd="${command} ${sendmail_submit_flags}"
-	run_rc_command "$1"
+	/etc/rc.d/sendmail-submit $1
 fi
-
 if checkyesno sendmail_outbound_enable; then
-	name="sendmail_outbound"
-	rcvar=`set_rcvar`
-	start_cmd="${command} ${sendmail_outbound_flags}"
-	run_rc_command "$1"
+	/etc/rc.d/sendmail-outbound $1
+fi
+if checkyesno sendmail_msp_queue_enable; then
+	/etc/rc.d/sendmail-msp-queue $1
 fi
-
-name="sendmail_clientmqueue"
-rcvar="sendmail_msp_queue_enable"
-start_cmd="${command} ${sendmail_msp_queue_flags}"
-pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
-required_files="/etc/mail/submit.cf"
-run_rc_command "$1"
Index: etc/rc.d/sendmail-msp-queue
===================================================================
RCS file: etc/rc.d/sendmail-msp-queue
diff -N etc/rc.d/sendmail-msp-queue
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/sendmail-msp-queue	12 Mar 2008 18:51:33 -0000
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: mail
+# REQUIRE: LOGIN cleanvar
+#
+#	we make mail start late, so that things like .forward's are not
+#	processed until the system is fully operational
+
+. /etc/rc.subr
+. /etc/mail/sendmail.subr
+
+name="sendmail_clientmqueue"
+rcvar="sendmail_msp_queue_enable"
+required_files="/etc/mail/submit.cf"
+start_precmd="sendmail_prestart"
+
+load_rc_config $name
+command=${sendmail_program:-/usr/sbin/sendmail}
+pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
+procname=${sendmail_procname:-/usr/sbin/sendmail}
+start_cmd="${command} ${sendmail_msp_queue_flags}"
+
+sendmail_prestart()
+{
+	rebuild_aliases
+}
+
+# Pre-cook sendmail related knobs before continuing.
+adjust_sendmail_knobs
+
+run_rc_command "$1"
Index: etc/rc.d/sendmail-outbound
===================================================================
RCS file: etc/rc.d/sendmail-outbound
diff -N etc/rc.d/sendmail-outbound
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/sendmail-outbound	12 Mar 2008 18:51:11 -0000
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: mail
+# REQUIRE: LOGIN cleanvar
+#
+#	we make mail start late, so that things like .forward's are not
+#	processed until the system is fully operational
+
+. /etc/rc.subr
+. /etc/mail/sendmail.subr
+
+name="sendmail_outbound"
+rcvar=`set_rcvar`
+start_precmd="sendmail_prestart"
+
+load_rc_config $name
+command=${sendmail_program:-/usr/sbin/sendmail}
+pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
+procname=${sendmail_procname:-/usr/sbin/sendmail}
+start_cmd="${command} ${sendmail_outbound_flags}"
+
+sendmail_prestart()
+{
+	rebuild_aliases
+}
+
+# Pre-cook sendmail related knobs before continuing.
+adjust_sendmail_knobs
+
+run_rc_command "$1"
Index: etc/rc.d/sendmail-submit
===================================================================
RCS file: etc/rc.d/sendmail-submit
diff -N etc/rc.d/sendmail-submit
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ etc/rc.d/sendmail-submit	12 Mar 2008 18:50:50 -0000
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: mail
+# REQUIRE: LOGIN cleanvar
+#
+#	we make mail start late, so that things like .forward's are not
+#	processed until the system is fully operational
+
+. /etc/rc.subr
+. /etc/mail/sendmail.subr
+
+name="sendmail_submit"
+rcvar=`set_rcvar`
+start_precmd="sendmail_prestart"
+
+load_rc_config $name
+command=${sendmail_program:-/usr/sbin/sendmail}
+pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
+procname=${sendmail_procname:-/usr/sbin/sendmail}
+start_cmd="${command} ${sendmail_submit_flags}"
+
+sendmail_prestart()
+{
+	rebuild_aliases
+}
+
+# Pre-cook sendmail related knobs before continuing.
+adjust_sendmail_knobs
+
+run_rc_command "$1"

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?584bfc3f0803122336r96f4033pc0e25a7324fb0486>