From nobody Mon Nov 4 14:55:57 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 4Xhvfj3nbHz5cB3r; Mon, 04 Nov 2024 14:55:57 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xhvfj37nfz4XVG; Mon, 4 Nov 2024 14:55:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730732157; 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=SjweT/vFy2IOyfVNhz1Jd1HCGhK1etP9+9PHAX2Dia4=; b=ulg2gLJO1DfC+Xj1SrJGuDd6qUvtcP2ltLfATkzC5kX36+3wLtfJvgsk1HvQcPNwkedrQY NeR1oWaCyzPiApG3a6mdjtysru5L8Md0r5Y4UkBuBgFHyUwxjLHBE2o2L+xWVte0XDEeJP hN1Snjppyv8WKmCrQryijTvE6EP7t+Rapxj/z2T8pnEckInMvSaLRkeLq8y8Y/jOdV2kTE Kj7xphvHRNqJRHBWlyydYs6M+CPiKITA28DhgYVR4AAUwzBKz1isF4LPOwkXJKmMXJ5aM+ dmBiE1XhK4pELMFNS8acNfFhUOC4xgygyDE5U5PDQNRs53sQn2FMwxP3led+WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730732157; 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=SjweT/vFy2IOyfVNhz1Jd1HCGhK1etP9+9PHAX2Dia4=; b=OjB5X/1O1+1vbTVGIIHsrcPrkbnaPEzceGXaXzq6/fQF8MCfATGqFDZ6eFbyfFoSGVQ1HE WzK5SJl+mBwCedifKBCAe9ifH/ENRrgsN8mUa/mtY7SQs249oCXp2vMblpMEs2pT59QXzU fGPUdrRohQ+MfyK/99A+p5keJYf2O7YduLMJ6rrc3xoElBhVg823vn6kqIHyYtWfwEYY2Z rOzC1PlXsNAb4JaKbRr+af2cKhbsbXNXejQFiXZhdsr81e9Twm/lE2L2BeumMc0JjNng13 JxchxTCTfJF6+JlOe7MSf9ltqQLTv0Vqy3JAqW+08rSHsUR7sJns0akrAWTxBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730732157; a=rsa-sha256; cv=none; b=pLCZ5AZ8MFkpl/YXEb82ATZzHRtzE+y1C2cLKG/CzUkIvOhnv+GY1X6AJhfkqWHjghwCYN X8Q0VPNrRQzF7hDu3DHnt+4Gjs7jb2CVjy6Oxws+zZpjbKwtdvikNNIOvQvrM4FSn99R6/ ZXWIGpnnBGn2GiY/mjS4qAACVLny9wYvX+xkKm6DBLM2wP99tIJ8rYXZ29IsX9f82/phb/ 2gUtgbHyBDKDHJbEHzrKbJnhqk6GaUg0NP/yG40lklBTB/0vc1rmzv3Y+8MwCovq55ed/r I2eCJuvd0NQMPCkJbzrUDCx7+Hk8NLZuHDdeTMZZZGClMqnDCQc+OkSVZjNZ3A== 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 4Xhvfj2J17zdZV; Mon, 4 Nov 2024 14:55:57 +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 4A4EtvQC059154; Mon, 4 Nov 2024 14:55:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A4Etve0059151; Mon, 4 Nov 2024 14:55:57 GMT (envelope-from git) Date: Mon, 4 Nov 2024 14:55:57 GMT Message-Id: <202411041455.4A4Etve0059151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 4ff71ffaa79b - stable/14 - rc.d/sendmail: Return non-zero if the daemon fails to start or is not running 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: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4ff71ffaa79b4b609b70b60d716faffce768bb41 Auto-Submitted: auto-generated The branch stable/14 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ff71ffaa79b4b609b70b60d716faffce768bb41 commit 4ff71ffaa79b4b609b70b60d716faffce768bb41 Author: Mateusz Piotrowski <0mp@FreeBSD.org> AuthorDate: 2024-10-21 10:10:52 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2024-11-04 14:55:40 +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 (cherry picked from commit d2e7bb630b83848a774d8213014a9e0747775019) --- 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 ea97503890f9..28d6818eabac 100755 --- a/libexec/rc/rc.d/sendmail +++ b/libexec/rc/rc.d/sendmail @@ -204,6 +204,7 @@ sendmail_precmd() } run_rc_command "$1" +_ret=$? required_files= @@ -212,6 +213,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 @@ -219,6 +221,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" @@ -227,3 +230,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")