From nobody Tue Dec 31 13:20:51 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YMtrg2FLqz5jRZv; Tue, 31 Dec 2024 13:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YMtrg1MWSz4kKh; Tue, 31 Dec 2024 13:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735651251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rVa1FKptYiutsznUX7cvIc3iVfSBzFHGaSPVbIRO+SQ=; b=cN5jXmd0Y/JpvtTB1sWENhQjXxTKWA1O1mTrqKfCPMkzjRFLtQ5iz5TxfA+R9/zKIgs51P VNs3LZPhmc26ZQfqVI9ywqXThjPNDrYs2JKva2aiiYtKkbj+LyO5Iub1w6C/2En8X61Rtf MUiHSMfWDjGmwuESolcfW9SUxkdqy31CTg+4vnVBmJK2AT3oNJLUwlk4FzcV/dhWGVGQ82 9qyQ53aYUK8o8w//78fDW4SG0jPINWjATPGJPncZ1WO/v0NNGhEq45jxZzPTIn9NPwmVmb 9DXfBPrpQJWksXZh8jHRbGfeu20AwD7iVJm4nMNPnCPihgCTDr0Cc8O+5B1SBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735651251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rVa1FKptYiutsznUX7cvIc3iVfSBzFHGaSPVbIRO+SQ=; b=aE0mnP163NEj0lRHkrFmD3tqaE+R3FZ8itZwyYo2LHMZlIZhoV0rj0WKuwG5wBPZI2p7I6 GdFvfOyat06vDSpwuSoLniz4ZhysReBYw7BN9WshloFQpqdLe+XB/zZDW0iZ4EZ5u+0N3t emGq+SIiUnOIFBpiTomUStQgOh8p93hKj6VR7sVPa8zyN2Y3e1ILsuSwJYU4bZirbPLgq+ NPxUk/bDQZ0irCdGozCzMmhYKU6tX1RzLSFeJdgbCBzMGBAh5YWJNNQh5rgZV0ZY8P+0oD sTMVVoF32sgdG+1IZDgxGehphovMLHt5CpAD+4Supm3CV7ym5I2y7qLe5Ou7Cw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735651251; a=rsa-sha256; cv=none; b=Y4NJffcCKSz0qfxE+c799DqGAFWg37bvxbqYTBMuCK9lnYChDqc5xQtiS4wT9KHSAbAi+y f3cfDMzvHe3BzMaJJ1NvreNfdosCWweeYTEoTd7Of/43OP3fZ64HoCKZCt0UHErZES4K1Y 28N+x4PphCtBL3bTWSG2rMrPCBTff1kJbxLCV9wWJP9lLHOPbeYdkQKAi+HZ9EDEJY/Nrv mea5iM+JzHgPXq3+sRriA7HdUo9zHSYWdiyZBD5+hGInornU3XDp5QfRZNy9QTVN0uJ3mc XYiOGWzua+MwAXhlyptsfUxXSnoXrMCMz07Pk1je8bvJrfRrq/X8tHZFq+hRRQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YMtrg0ym2zgsm; Tue, 31 Dec 2024 13:20:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BVDKpuK079011; Tue, 31 Dec 2024 13:20:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BVDKpBU079008; Tue, 31 Dec 2024 13:20:51 GMT (envelope-from git) Date: Tue, 31 Dec 2024 13:20:51 GMT Message-Id: <202412311320.4BVDKpBU079008@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Tijl Coosemans Subject: git: fb3408bb6e5b - stable/14 - rc.d/sendmail: Fix error with some configurations List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tijl X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fb3408bb6e5b7bebe8800d9f08579d9dc6236b81 Auto-Submitted: auto-generated The branch stable/14 has been updated by tijl: URL: https://cgit.FreeBSD.org/src/commit/?id=fb3408bb6e5b7bebe8800d9f08579d9dc6236b81 commit fb3408bb6e5b7bebe8800d9f08579d9dc6236b81 Author: Tijl Coosemans AuthorDate: 2024-12-03 10:45:10 +0000 Commit: Tijl Coosemans 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")