From nobody Tue Jul 22 09:24:59 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 4bmX0r3hzlz62nRt; Tue, 22 Jul 2025 09:25:00 +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 4bmX0q6F73z3xVs; Tue, 22 Jul 2025 09:24:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753176299; 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=LWUPy8cRtTx3MKPdOAQnrbYCdHKCLVq1fTa3tcOsHAo=; b=Lad430rRA7ZZyreO5qS0fg3saF2ox7zcyCXsWE5taXrraByqKzCUg+yANALW7PX+s2+2KC VycdxVxIzllz9sF7IxI3czCTzBNUM8y1JEBOvQJ290Bpkpj+meiuzTCRvLJMqLFDrTdpRx ok1RZcDQ4C+TMpKpMkDqSNUgRTTUBoPNjtZFXcOOpfKcUlDmKbuP4Of78K/mL0R1UneJGa TIf4rl+ny5N55OzZc0AI6ueEcO3dxnrje938hkXKVdhDHjwQ+x2vm3KCIMStbdk03/4mB5 5sjOymzKE0zH1QA6+1GKxQ9nlghtIUediVmafcxFotp+7WGJeUS8buGxZGSHgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753176299; 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=LWUPy8cRtTx3MKPdOAQnrbYCdHKCLVq1fTa3tcOsHAo=; b=r/jk7L6gM+feI4fF/5yJy2zlduCwMhg6HV/GiD4KgpkFyKatrtWyZY2LEqm+m4v+RZFpqc rDbOxHSb/FwQ87mnetP96zgo8GbXIFfD6R/N+Yw8pQ+MaVKk72lDzPdPfesIW/pAjLSia+ GT44jm0UR4m9joilPohucay30yRwArUuGmhhQsN8S0Y/yTWyCQvwi/XBxom+F1D6isrFs3 AKGl2s9PwZCn7JRGfnkGFYEKjXe9CGzYlQZxv3r2PCYvtBxy/g+qxfC+Cw1U55JF0l/KJt 6glONeSGurStzz4ibru8AKyQ6GWsTELlf/TcF/4rSNYAfCzPEC91FNjt3+UTwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753176299; a=rsa-sha256; cv=none; b=fOxAO1FmHcVD5FCwkJ6vVQCdzax2U0g/lPk4q3fpIMQB6aDsI7RT5Z7F3GdgOnBVuE/dn0 fXSWk7qKspi5+n6HWLPJsBq+hCpYQuI6xHDmG52+70IiyRqVccHdfxU3Fixd1jjse7cut/ MbuTon52Ipjl3W5GTAzHIvJE8MfiXm9Rp1E59jFXbMZK5FHRkWJpke6VZ49DpLpxd+KF/L f/fVvwqr12UyCfHizJOyXYIY8m2Jlr83VxCe/8zBsm+m+Me3ESPUHEU4DPhO/1kDaxyN38 YyH+vJv2E7RabtfBPj0UT3XyKpSdhBbm+urHeI22azG1LFgmBIFdFHUlpH0iog== 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 4bmX0q5ryrz6BT; Tue, 22 Jul 2025 09:24:59 +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 56M9OxYE043366; Tue, 22 Jul 2025 09:24:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56M9OxdF043363; Tue, 22 Jul 2025 09:24:59 GMT (envelope-from git) Date: Tue, 22 Jul 2025 09:24:59 GMT Message-Id: <202507220924.56M9OxdF043363@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: 94c1c907f8c7 - main - reboot(8): add support for 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: 94c1c907f8c78d8c8ad34b6a7d374384f8fb71b6 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=94c1c907f8c78d8c8ad34b6a7d374384f8fb71b6 commit 94c1c907f8c78d8c8ad34b6a7d374384f8fb71b6 Author: Konstantin Belousov AuthorDate: 2025-07-10 23:58:46 +0000 Commit: Konstantin Belousov CommitDate: 2025-07-22 09:22:06 +0000 reboot(8): add support for noshutdown Similar to shutdown(8), refuse to reboot if /var/run/noshutdown is present. The -f option can be used to force operation. Reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D51241 --- sbin/reboot/reboot.8 | 9 +++++++++ sbin/reboot/reboot.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 0ddcee643244..1bbc39d52be4 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -110,6 +110,15 @@ Care should be taken if .Va value contains any characters that are special to the shell or loader's configuration parsing code. +.It Fl f +Force reboot. +Normally, +.Nm +checks for the presence of the next kernel, +and absence of the +.Pa /var/run/noshutdown +file. +Without this flag, reboot is denied if one of the conditions failed. .It Fl k Ar kname Boot the specified kernel .Ar kname diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 9825d4f96319..f6065e80fb66 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,7 @@ main(int argc, char *argv[]) { struct utmpx utx; const struct passwd *pw; + struct stat st; int ch, howto = 0, i, sverrno; bool Dflag, fflag, lflag, Nflag, nflag, qflag; uint64_t pageins; @@ -294,6 +296,11 @@ main(int argc, char *argv[]) if (argc != 0) usage(); + if (!donextboot && !fflag && stat(_PATH_NOSHUTDOWN, &st) == 0) { + errx(1, "Reboot cannot be done, " _PATH_NOSHUTDOWN + " is present"); + } + if (Dflag && ((howto & ~RB_HALT) != 0 || kernel != NULL)) errx(1, "cannot delete existing nextboot config and do anything else"); if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT))