From nobody Sat May 10 19:33:17 2025 X-Original-To: dev-commits-src-branches@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 4ZvwyQ4Ddxz5vkkx; Sat, 10 May 2025 19:33:18 +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 4ZvwyQ19THz3TNb; Sat, 10 May 2025 19:33:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746905598; 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=xXk3TcDV1RcsqWfUJXfkIAIhQIjpkMvpVddfRXQKIWs=; b=HtIKAwygEI8ySkUMOT8NqrQFfHd8ysSuUDOuB+PjOzikL5a3OPt7+e2z/Yu3rO3Rdq52W/ DqH/E2eRI3FYe2KS++9HE+BRI31N0wxhBqvs0a7482ygsRYaF49E4xMM3pMRldB7OZKRAM u2CE9PAogmcSR1V52JOi0yQlwnk41Ykdw+xJmNiL/ovxs0L/LnbPalYng4661TgPD80J0K ukcnNdKY3bRnjyr32Pt+jhlTGRUQxPEwkjTLw25OZ5bci2mM7+fWftS+yU2X2V2a+FoudW hA+kunybU975xnsFf2G3oo6zIexzFLUn3orYENWblU4yEIQK80c88qll5pbvLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746905598; 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=xXk3TcDV1RcsqWfUJXfkIAIhQIjpkMvpVddfRXQKIWs=; b=LRjYWg6pJSQf9RvqBuxM23oLkx5JGg72eoEwV7fJ8f5K1GsZxAuBgGt7BvTnQZb0WnJJ9S Zhg3jexdLi30o7unee1k7+CopiAKdWJ52rgPGQNN8YKsNHjkwmpsiNk+LmZtuCun8klTOF gZDmmAznIA8h5VMOYmMnsxACAMtct5vhEw3sQIAqwX3jjba0xxLKmofSw/VCo78KEnrQI4 mVSvoEH/ZWuqNeM8q7Y96X6GYTbAY3+bdTyhCzfkQBkWtRxHWYMfMcOFQaR1rzBrGg/xBJ QRbrxTz4yg13V4Vs52kfs1zFcoFSSBahZ44de6K4dLhztOdpmN+GOed/brsDQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746905598; a=rsa-sha256; cv=none; b=nQriTM2hmSq5ZbY/lvu05PVY7bq6GR52vZFJnjLNA5oQxRmUiwAjyOzEUu9Ny9CHZw2ELN W4F0AU2+LaE0TpPu593t1Wtf04KVh6TjKV1a3ayfHq6lBD3BvY2nX7BDj5nBfm6DPLsiNa U+Fb2E+HhTZTsiiZWoldbdnXqasHTaduLgxhB+WBGEmvOz+KFhn67DkjqYEDV0xtSPS32g xxHZDnClLZJh8ynKOcPual8B2YfHKhWpbwEla8G5f7/OMn7jFIm0trXlW2yE4nU1pMyxoR A36Ch7tUrtVTMkIP//e2W2RXiN7vb/TnXNncegW42+2lgQFc26AmdymGy+foug== 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 4ZvwyQ0lHSzyqv; Sat, 10 May 2025 19:33:18 +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 54AJXIA5055232; Sat, 10 May 2025 19:33:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54AJXHRd055228; Sat, 10 May 2025 19:33:17 GMT (envelope-from git) Date: Sat, 10 May 2025 19:33:17 GMT Message-Id: <202505101933.54AJXHRd055228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8cb3670fb90e - stable/14 - rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 8cb3670fb90ebe14ea609cd576f5dc235814f8b1 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cb3670fb90ebe14ea609cd576f5dc235814f8b1 commit 8cb3670fb90ebe14ea609cd576f5dc235814f8b1 Author: Konstantin Belousov AuthorDate: 2025-05-04 13:51:26 +0000 Commit: Konstantin Belousov CommitDate: 2025-05-10 18:57:46 +0000 rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown (cherry picked from commit 384d976725a5c29734a9227fcdb6ef0807485c91) --- 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 3f8b0ae7b42f..b3c54c3cb0f0 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 320408d5d62c..e218ecf516d1 100644 --- a/libexec/rc/rc.d/Makefile +++ b/libexec/rc/rc.d/Makefile @@ -67,6 +67,7 @@ CONFS= DAEMON \ nfsd \ nfsuserd \ nisdomain \ + noshutdown \ ${_nscd} \ ntpdate \ ${_opensm} \ 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"