Page MenuHomeFreeBSD

rc.d/sendmail: Return non-zero if the daemon fails to start or is not running
AcceptedPublic

Authored by 0mp on Tue, Oct 1, 1:33 PM.
Tags
Referenced Files
Unknown Object (File)
Fri, Oct 4, 4:06 PM
Unknown Object (File)
Wed, Oct 2, 10:22 AM

Details

Summary

If you have a mail server that is running sendmail daemon
(sendmail_enable=YES) and sendmail queue runner (sendmail_msp_queue=YES)
and the sendmai 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.
If the sendmail_msp_queue is not running, it will return non zero as the
exit code.

PR: 223132


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223132

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59676
Build 56562: arc lint + arc unit

Event Timeline

0mp requested review of this revision.Tue, Oct 1, 1:33 PM
0mp added subscribers: jilles, eugen_grosbein.net.

This is a stopgap. A proper fix would require a rewrite of this service script and possibly a split of the different functionalities of this script into separate files.

I think this patch is a fair workaround for the issues reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223132.

What is unclear to me is whether we should expand this patch to preserve the exit code of sendmail_submit and sendmail_outbound.

0mp edited the summary of this revision. (Show Details)

LGTM. Only a minor nit: in the commit message there is a typo: "sendmai daemon ...".

This revision is now accepted and ready to land.Wed, Oct 16, 10:36 AM
libexec/rc/rc.d/sendmail
233

Should these be $_ret?

This should have some comment explaining what is going on.

libexec/rc/rc.d/sendmail
233

I think you only specify the variable name without $ if it's inside $((...)).

libexec/rc/rc.d/sendmail
233

I see that we use both styles in the tree.

0mp marked 3 inline comments as done.Wed, Oct 16, 4:18 PM
0mp added inline comments.
libexec/rc/rc.d/sendmail
233

It is recommended by shellcheck to let $(()) expand variables on its own. $? has to be used as a variable in this case, however, because just ? has a different meaning in this context.

0mp marked an inline comment as done.Wed, Oct 16, 4:19 PM
0mp added inline comments.
libexec/rc/rc.d/sendmail
233

Both $(($foobar)) and $((foobar)) is valid sh.