git: fb3408bb6e5b - stable/14 - rc.d/sendmail: Fix error with some configurations
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 31 Dec 2024 13:20:51 UTC
The branch stable/14 has been updated by tijl:
URL: https://cgit.FreeBSD.org/src/commit/?id=fb3408bb6e5b7bebe8800d9f08579d9dc6236b81
commit fb3408bb6e5b7bebe8800d9f08579d9dc6236b81
Author: Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-12-03 10:45:10 +0000
Commit: Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-12-31 13:16:10 +0000
rc.d/sendmail: Fix error with some configurations
The sendmail startup script can run 4 daemons: sendmail, sendmail_submit,
sendmail_outbound, and sendmail_msp_queue. Of the first 3 at most one
can be enabled. There's a run_rc_command call for each and the ones for
sendmail and sendmail_msp_queue run unconditionally. For some rc
commands this triggers warnings or errors when sendmail_enable="NO" or
sendmail_msp_queue_enable="NO". Since d2e7bb630b83 these errors are
propagated and the whole script fails.
Fix this by first determining which daemons are enabled, setting ${name}
and ${rcvar} accordingly, and then always calling run_rc_command
conditionally.
Also replace ${name}.cf with sendmail.cf because ${name} isn't always
sendmail.
PR: 282585
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D47757
(cherry picked from commit 6b17d944a1d448dbb797c5fa5b0778242ba02e52)
---
libexec/rc/rc.d/sendmail | 49 +++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/libexec/rc/rc.d/sendmail b/libexec/rc/rc.d/sendmail
index 28d6818eabac..97cd6fcfddce 100755
--- a/libexec/rc/rc.d/sendmail
+++ b/libexec/rc/rc.d/sendmail
@@ -40,11 +40,28 @@ esac
if checkyesno sendmail_enable; then
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
+ _sendmail_run=true
fi
# If sendmail_submit_enable=yes, don't need outbound daemon
if checkyesno sendmail_submit_enable; then
+ name="sendmail_submit"
+ rcvar="sendmail_submit_enable"
sendmail_outbound_enable="NO"
+ _sendmail_run=true
+fi
+
+if checkyesno sendmail_outbound_enable; then
+ name="sendmail_outbound"
+ rcvar="sendmail_outbound_enable"
+ _sendmail_run=true
+fi
+
+if checkyesno sendmail_msp_queue_enable; then
+ _sendmail_msp_queue_run=true
+else
+ # Make sure run_rc_command is called at least once.
+ _sendmail_run=true
fi
sendmail_cert_create()
@@ -164,8 +181,8 @@ sendmail_precmd()
# Die if there's pre-8.10 custom configuration file. This check is
# mandatory for smooth upgrade. See NetBSD PR 10100 for details.
#
- if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
- if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
+ if checkyesno ${rcvar} && [ -f "/etc/sendmail.cf" ]; then
+ if ! cmp -s "/etc/mail/sendmail.cf" "/etc/sendmail.cf"; then
warn \
"${name} was not started; you have multiple copies of sendmail.cf."
return 1
@@ -203,33 +220,19 @@ sendmail_precmd()
fi
}
-run_rc_command "$1"
-_ret=$?
-
-required_files=
-
-if checkyesno sendmail_submit_enable; then
- name="sendmail_submit"
- rcvar="sendmail_submit_enable"
- _rc_restart_done=false
+if ${_sendmail_run:-false}; then
run_rc_command "$1"
- _ret=$(( _ret > $? ? _ret : $? ))
fi
+_ret=$?
-if checkyesno sendmail_outbound_enable; then
- name="sendmail_outbound"
- rcvar="sendmail_outbound_enable"
+if ${_sendmail_msp_queue_run:-false}; then
+ name="sendmail_msp_queue"
+ rcvar="sendmail_msp_queue_enable"
+ pidfile="${sendmail_msp_queue_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
+ required_files="/etc/mail/submit.cf"
_rc_restart_done=false
run_rc_command "$1"
_ret=$(( _ret > $? ? _ret : $? ))
fi
-name="sendmail_msp_queue"
-rcvar="sendmail_msp_queue_enable"
-pidfile="${sendmail_msp_queue_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
-required_files="/etc/mail/submit.cf"
-_rc_restart_done=false
-run_rc_command "$1"
-_ret=$(( _ret > $? ? _ret : $? ))
-
(exit "$_ret")