Date: Wed, 6 Nov 2024 01:10:17 +0100 From: =?UTF-8?B?VMSzbA==?= Coosemans <tijl@FreeBSD.org> To: Mateusz Piotrowski <0mp@FreeBSD.org> Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: d2e7bb630b83 - main - rc.d/sendmail: Return non-zero if the daemon fails to start or is not running Message-ID: <20241106011017.68146ea9@hal.tijl.coosemans.org> In-Reply-To: <202410211921.49LJLj5t024751@gitrepo.freebsd.org> References: <202410211921.49LJLj5t024751@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 21 Oct 2024 19:21:45 GMT Mateusz Piotrowski wrote: > The branch main has been updated by 0mp: > > URL: https://cgit.FreeBSD.org/src/commit/?id=d2e7bb630b83848a774d8213014a9e0747775019 > > commit d2e7bb630b83848a774d8213014a9e0747775019 > Author: Mateusz Piotrowski <0mp@FreeBSD.org> > AuthorDate: 2024-10-21 10:10:52 +0000 > Commit: Mateusz Piotrowski <0mp@FreeBSD.org> > CommitDate: 2024-10-21 19:20:36 +0000 > > rc.d/sendmail: Return non-zero if the daemon fails to start or is not running > > If you have a mail server that is running sendmail daemon > (sendmail_enable=YES) and sendmail queue runner (sendmail_msp_queue=YES) > and the sendmail daemon dies, /etc/rc.d/sendmail status does see the > daemon is not running but returns 0 as the exit code. This prevents > other programs (like puppet) from restarting sendmail to fix the issue. > > Make sure that the exit code is propagated towards the end of the script > if any of the sendmail services fail. > > This patch does not call exit directly but instead just sets the exit > status code by calling exit in a subshell. This way we do not exit the > current shell in case the service script is sourced (e.g., when > rc_fast_and_loose is active). > > PR: 223132 > MFC after: 2 weeks > Reported by: pirzyk > Discussed with: jilles, eugen > Reviewed by: christos, gshapiro (previous version), markj > Approved by: christos (mentor), markj (mentor) > Differential Revision: https://reviews.freebsd.org/D46862 > Co-authored-by: Jim Pirzyk <pirzyk@FreeBSD.org> > --- > libexec/rc/rc.d/sendmail | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/libexec/rc/rc.d/sendmail b/libexec/rc/rc.d/sendmail > index af84c6d6b548..5a780e5b15a1 100755 > --- a/libexec/rc/rc.d/sendmail > +++ b/libexec/rc/rc.d/sendmail > @@ -206,6 +206,7 @@ sendmail_precmd() > } > > run_rc_command "$1" > +_ret=$? > > required_files= > > @@ -214,6 +215,7 @@ if checkyesno sendmail_submit_enable; then > rcvar="sendmail_submit_enable" > _rc_restart_done=false > run_rc_command "$1" > + _ret=$(( _ret > $? ? _ret : $? )) > fi > > if checkyesno sendmail_outbound_enable; then > @@ -221,6 +223,7 @@ if checkyesno sendmail_outbound_enable; then > rcvar="sendmail_outbound_enable" > _rc_restart_done=false > run_rc_command "$1" > + _ret=$(( _ret > $? ? _ret : $? )) > fi > > name="sendmail_msp_queue" > @@ -229,3 +232,6 @@ 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") Running "make stop" in /etc/mail now produces an error with the following config in /etc/rc.conf: sendmail_enable="NO" sendmail_msp_queue_enable="YES" sendmail_outbound_enable="YES" sendmail_submit_enable="YES"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20241106011017.68146ea9>