From nobody Mon May 05 16:05:26 2025 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 4ZrmZv0ytJz5vh4t; Mon, 05 May 2025 16:05:27 +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 4ZrmZt6YN5z3K1Q; Mon, 05 May 2025 16:05:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746461126; 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=IJHMFL8hE0fEUGriiQDlr6dCwBPo/87q6W22Ipodt/4=; b=pI6pECTXG2cw/l2b/SiuU2w6JGq6q8ROTcy5FmXLiT/KH1jZKMYjEW2N/y3GT2rRWeXY5d H8xGcg5DlLNiC2udUpBlwXvzwLN6B42Ylj0Qt9ZB6wHhqD1Gp/smApnu2e6LnQddpiXSgq ai5qwbhoEegsG3MUwrKpRZiQ3ZP//CVptHFfOZwma7QY/qy/2WG7ZVvGjoLf/GmOJbhJh1 1uq81+HPlzs5LhCddLLE2bjidw4n4M8cWUtvV1840v4aoq/W5IEBbsjHoQxjHczuMEFTLm 60t4pKhYlAXvRV9x/EOGdhhK1M4qUynD/rv0cVPuTni+B95SbsGT7ST/mo841w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746461126; 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=IJHMFL8hE0fEUGriiQDlr6dCwBPo/87q6W22Ipodt/4=; b=xQ+EQe1l7Jzpc5doger5D23pALm3E549gTDx+v4RGwsssk6AVHNn1kSYUXix3lflYEP0gi iij0sReuVTPiuNQZnJOK1cKjvS0b1dwE2I3W2YKenankTmFhod3VoOvW/Q0hiIm092MV3+ sq2ck/dvzl5M2eRN90z/lm6mribIc0RqDy9t/I1kw1ABNLBQaMUwleHdi0bwlJpSOx0OK6 YRZkA5T7cGeEuXwfqjJd18jWU9GQX2xRo7Ep/cNn/Hj3uv5Vj8Z5vq6UHGtr1OF6tTPylK eRROcPTsdBMtzLajk3Ym7LOCI5Oj56Kl8y5QZKhLLjOqsIL1j0vmIXx9sSj7vw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746461126; a=rsa-sha256; cv=none; b=gTUeagim4r9Upc7cHnbMJ4Qhz77AxlK74qi/GpyOUZS+BHmV9DxByfyAzx5ZN9pqFQMi2p OjSViKN977oGzCCUwO1ds/xxIWACUU1ghesqcpKHtIg6pAnSPz0gBoRhs2VtXk45UJer9P MPK04TJq/2V8fAmZIbZIyDxdcIrnyyp07oO0Ln6oALTj9/xf7WpUMYUi1zoofmUiWaPL3+ kIWHS/VqtRWiMqwJnH13S2VQMiyz2PdxtVc8Y8Og82FDaEM5BqzXeTX5xIGEQCCOZcfQm4 +197a2w08cIjMiedaLR2n6HNVJvA+SwlM7cXcDckdrduJSKnWovLgiaJo3qVvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4ZrmZt692Hz4tW; Mon, 05 May 2025 16:05:26 +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 545G5QhP053156; Mon, 5 May 2025 16:05:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 545G5QaO053153; Mon, 5 May 2025 16:05:26 GMT (envelope-from git) Date: Mon, 5 May 2025 16:05:26 GMT Message-Id: <202505051605.545G5QaO053153@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 384d976725a5 - main - rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 384d976725a5c29734a9227fcdb6ef0807485c91 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=384d976725a5c29734a9227fcdb6ef0807485c91 commit 384d976725a5c29734a9227fcdb6ef0807485c91 Author: Konstantin Belousov AuthorDate: 2025-05-04 13:51:26 +0000 Commit: Konstantin Belousov CommitDate: 2025-05-05 16:05:03 +0000 rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown Reviewed by: bapt, kevans, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D50166 --- libexec/rc/rc.conf | 2 ++ libexec/rc/rc.d/Makefile | 1 + libexec/rc/rc.d/noshutdown | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 9540cca6c2f1..cfb4fa09b1c1 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -29,6 +29,8 @@ rc_info="NO" # Enables display of informational messages at boot. rc_startmsgs="YES" # Show "Starting foo:" messages at boot rcshutdown_timeout="90" # Seconds to wait before terminating rc.shutdown +precious_machine="NO" # Set to YES to get some guards against mis-directed + # shutdown(8) commands early_late_divider="FILESYSTEMS" # Script that separates early/late # stages of the boot process. Make sure you know # the ramifications if you change this. diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile index 52b48a53c196..89eeea8f587a 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -51,6 +51,7 @@ CONFS= DAEMON \ netif \ netoptions \ netwait \ + noshutdown \ ${_nscd} \ ${_opensm} \ os-release \ diff --git a/libexec/rc/rc.d/noshutdown b/libexec/rc/rc.d/noshutdown new file mode 100755 index 000000000000..54924310a6c7 --- /dev/null +++ b/libexec/rc/rc.d/noshutdown @@ -0,0 +1,31 @@ +#!/bin/sh +# +# + +# PROVIDE: noshutdown +# REQUIRE: var +# BEFORE: LOGIN + +. /etc/rc.subr + +name="noshutdown" +desc="Disable shutdown(8) for precious machines" +rcvar="precious_machine" +start_cmd="noshutdown_start" +stop_cmd="noshutdown_stop" + +: ${noshutdown_file:="/var/run/noshutdown"} + +noshutdown_start() +{ + touch $noshutdown_file +} + +noshutdown_stop() +{ + rm -f $noshutdown_file +} + +load_rc_config $name + +run_rc_command "$1"