From nobody Mon Oct 21 19:21:45 2024 X-Original-To: dev-commits-src-main@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 4XXQCs4vjnz5ZgCR; Mon, 21 Oct 2024 19:21:45 +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 4XXQCs4FNlz4VB4; Mon, 21 Oct 2024 19:21:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729538505; 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=43COYSn7QLlXIiKMyHueuHIDpQZ71aErKeRbM+KS72Q=; b=COz1SPBulyx8RyJ94QtFIn1RlGcbU5pfwgULcSLoBqBBCaYFnkbLI5wONWwX/FOUHJLuHY YdGz4Phfe7CovZonyTealmtTOWCSWcC3q2oJnTIRvQIMye8AIDrn7A/1p0WKtW524Ln071 zl76PZxnMSpCbvZV6JHRBIP2sqFYkk74spy8r3Q9A4DIi2rhm9S6DesTAJSrRJN/SX6aBX vJce1RbfF/2BR2bdDvfH1ScAUkzY/5PX3XMN+ZJBWLU/9I1mXhIWXFqsX78goAHIiO4ZmZ 2qLUMIKcucCWIk0Avtsvr902eNFIrNzp4lI8ZJyTmDTdbbRGwTUqGeADudwBSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729538505; 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=43COYSn7QLlXIiKMyHueuHIDpQZ71aErKeRbM+KS72Q=; b=D7PN6TUB4bwhh4OU0CfRVdgaCXFnK6VowxlCFQHvKoH+fOrybMEvSdGB8NBh3RcZildoNy TfzT9kltU2Qhl9FnbjRh2l2GTv6InWPinuG9VcPukdRhfCiV39zNwLDyLeb1xCsn0py++1 Hu+8M4Ko5eicq8x/wvnGTA8D7vKeJQMgO7NiPlaIkuCSH1kczDh866cQHSoRsjPqI7qIDl kP+gO5W1OTpt3BEeszUFTN7Vrwbm3rp/eupNkvp0imX2Xi3hhbbpx9LTceAHlwf20qOsFF BZ7eYED7qaNHpqX8NvKKwa1zZFshgY4t9jWFK+jsuJLP6a+j4GP7eo8GihiQtg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729538505; a=rsa-sha256; cv=none; b=VUpPRpGvAurXf7uR/3PYIJs2+u7F5cvDIQEWG6LYBKf/jNZV9aNXbW25ZAz5E5XYOWWZU+ mWTBNP288iJEVYcAD1tbT6RJABpeuF5tMOqSGS/LEplI5B4qi0ZHMjZ0bNraKs8RiYgKXF fhGKCvisKdjIGXXIF+qQ7aTygcRt0Uh/Hxr+LlqiW+THAxxYahZ45oGyK0Hbe0L6uakemL PDv3/tFdkLCzDFlHMWZwgey0g3uQSmxETXxnqfUrmbV6A3eb+uUe3913znP50KVsVKv/Tr 6ADWpYQE7Pz25x226znljmUlCpjONn6DTqd/BteK1Mz2hc1+rXaPKRKLl5UKMg== 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 4XXQCs3ZGtzjx7; Mon, 21 Oct 2024 19:21:45 +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 49LJLj4K024754; Mon, 21 Oct 2024 19:21:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49LJLj5t024751; Mon, 21 Oct 2024 19:21:45 GMT (envelope-from git) Date: Mon, 21 Oct 2024 19:21:45 GMT Message-Id: <202410211921.49LJLj5t024751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: d2e7bb630b83 - main - rc.d/sendmail: Return non-zero if the daemon fails to start or is not running List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: d2e7bb630b83848a774d8213014a9e0747775019 Auto-Submitted: auto-generated 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 --- 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")