From nobody Mon Nov 04 14:56:01 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 4Xhvfn617kz5cB3t; Mon, 04 Nov 2024 14:56:01 +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 4Xhvfn57Wbz4Y3q; Mon, 4 Nov 2024 14:56:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730732161; 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=NzpsV/OfIZGIuSmsqQ2G4X/+9pLbJI3qolZuyMcQzxc=; b=ZsFm82RobS9wdZHNh9X/+x003Kd2acycR6nSoHOO3ZGjpGbJ0Oo4ylx8chQJvjp3p0gfI8 +b2q/d+VlbwVXNTIB0NWbqi/NFNlbulAxZEqOeMYCpDEz+pCSdfRFt7v9WQ4BTMA7YRFot 6ZfEY4IoiylOMXWHFDXEnnj5dQeDH/PExmbrymzgSZqq83ejZObzxc+yIZT/L8K7v5T2E2 iYXAgdBW12dIp9zuIolWpwlJbyWtxNgZF5V6xpjY5Fr9JErKr+9TMgx1NKtvW4TM2XEm92 p/jEYPVHLR5x0G6s/OGaL1qxva2D6bGYZkZr6mkvlYmjeQe/R8foZqNYXoQNYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730732161; 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=NzpsV/OfIZGIuSmsqQ2G4X/+9pLbJI3qolZuyMcQzxc=; b=EVKcIFjODVL7Nh92J6yh6g9OcI3cMp2O61IAGIs5RAUJm79o3x8GA3Je6qSEg+QU3sAXff pAV3x5E40jjRYbjVwieKWtyr0Es6bEz8+GHMVjKEzb/HvNavlaQFGOozxeZMtr9dI3n+yh iee6bro+qv7kJHfyi+1ykwn6vsITHqlcoRWc0brqOqk/OC7bN04zrM0tBOVt7v0tMhCIrK PGcr2hlG7Y30tLFjel6lbBPHJ4EUH2XXgka5hTdgxiN7oXXsokV5MuFWYaMuqqqoTTJ7sv fKUbECeCbhCwIvAhQlLy/qqPs/UXRHb/7+3JSvrtGIUsk9fb6vhPaVPQXuQ0pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730732161; a=rsa-sha256; cv=none; b=DxC/D1HveSuzVrwDL3vQoruY7zlj9aaK+z9SG27Z4MYS1whd1YJOBU4BetMlgfDyaZ2lQ3 fST+e3vZt/F+wdPRgyDBz8ERDytD5KpcehWcPPEfz6bkfkn+Ek6Ulg9alr5TymCjNPqM2i SJntLGs/M+qaHvllvqV+XXuKkjocbxEsSiz2cUesKO7pbIggPt+BaczPRiqv3ViWHdPGHM bWKRDqoVOLYxUOYxhZ/+SS0jKDVBrqFZpRcUUBW5/D/+2D2q7GkI3wuIaf9peouOYKwUIO ejMClFndPiXbsyDAm92u2pWrcYYjtMNRCz+dgy+NReyBLhgA+MLfvHbZag1R3w== 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 4Xhvfn4X9NzdDC; Mon, 4 Nov 2024 14:56:01 +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 4A4Eu1Ar059334; Mon, 4 Nov 2024 14:56:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A4Eu1na059331; Mon, 4 Nov 2024 14:56:01 GMT (envelope-from git) Date: Mon, 4 Nov 2024 14:56:01 GMT Message-Id: <202411041456.4A4Eu1na059331@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: d36998a6cc68 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: d36998a6cc6853e54066d476d146e1b510976418 Auto-Submitted: auto-generated The branch stable/13 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=d36998a6cc6853e54066d476d146e1b510976418 commit d36998a6cc6853e54066d476d146e1b510976418 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:55 +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")