Re: sysctl to prevent reboot?

From: Bjoern A. Zeeb <bzeeb-lists_at_lists.zabbadoz.net>
Date: Thu, 10 Jul 2025 14:38:47 UTC
On Thu, 10 Jul 2025, Warner Losh wrote:

> On Thu, Jul 10, 2025, 8:30 AM Konstantin Belousov <kostikbel@gmail.com>
> wrote:
>
>> On Thu, Jul 10, 2025 at 01:51:47PM +0000, Bjoern A. Zeeb wrote:
>>> On Thu, 10 Jul 2025, Zhenlei Huang wrote:
>>>
>>> Hi,
>>>
>>>> I believe Konstantin's work [1] and  [2] are precisely what you need.
>>>>
>>>> [1]
>> https://cgit.freebsd.org/src/commit/?id=7fb88c20eccc3fd2118fda2ba58d7afe2b87f7e3
>> <
>> https://cgit.freebsd.org/src/commit/?id=7fb88c20eccc3fd2118fda2ba58d7afe2b87f7e3>
>>  shutdown(8): refuse to run if /var/run/noshutdown is present
>>>> [2]
>> https://cgit.freebsd.org/src/commit/?id=384d976725a5c29734a9227fcdb6ef0807485c91
>> <
>> https://cgit.freebsd.org/src/commit/?id=384d976725a5c29734a9227fcdb6ef0807485c91>
>> rc.d: Add precious_machine rc.conf knob to create /var/run/noshutdown
>>>
>>> Thanks!  I was looking in the wrong place.
>>>
>>> That doesn't catch reboot, does it?  For me that's the offending command
>>> as I type that at the loader prompt (if I am in the correct window).
>>
>> Reboot is very different from shutdown.  I never use it except on
>> nfs-booted
>> crash boxes, so I did not considered.
>>
>> If you think it is useful, I can add the check there too.

I don't use it either for the normal OS but it does something (extra
bad) if I type it and am not at the loader prompt as I thought I was.


> There have been other proposals that align reboot better with Linux's
> behavior, then a special check isn't needed.

There was a reason I originally thoguth it was a sysctl as that would
prevent any applicant binary modifications and probably would even catch
a signal to init but whatever it is or will be; catching reboot would be
good as that is the bad command from the loader.  "reset" thankfully
doesn't do any bad ...

Using alias feels too fragile to be honest.

Anyway; I an help myself now at least;  thanks!

-- 
Bjoern A. Zeeb                                                     r15:7