Page MenuHomeFreeBSD

Add a shutdown precaution measure
ClosedPublic

Authored by kib on May 5 2025, 10:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Aug 29, 9:10 AM
Unknown Object (File)
Tue, Aug 12, 10:03 AM
Unknown Object (File)
Jul 21 2025, 6:28 AM
Unknown Object (File)
Jul 18 2025, 4:46 AM
Unknown Object (File)
Jul 13 2025, 5:28 AM
Unknown Object (File)
Jul 8 2025, 3:57 PM
Unknown Object (File)
Jul 8 2025, 11:09 AM
Unknown Object (File)
Jul 7 2025, 11:45 AM
Subscribers

Details

Summary

After I rebooted the unintended machine N times due to typing poweroff in the wrong ssh session, I think it is worth to add some optional safety belts there, at least for me.

By default, nothing changes. If 'precious_machine' is set to true in rc.conf, the /var/run/noshutdown file is created on boot.

shutdown(8) refuses to do any changes to the system state if the file is present. User must manually remove it to get shutdown going.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.May 5 2025, 10:23 AM

This seems reasonable. I don't see how to implement this in a simpler fashion.

libexec/rc/rc.d/noshutdown
7

Since that touches things in /var/run (and var depends on mountcritremote).

What is the reason of requiring syslogd here ?

sbin/shutdown/shutdown.8
243

I love this, I am wondering if -i is the right option, the natural option I would have been looking for is -f for force, rather that -i for ignore, I don't think it is a big deal, and I am fine with -i

kib marked 2 inline comments as done.May 5 2025, 11:03 AM
kib added inline comments.
libexec/rc/rc.d/noshutdown
7

I experimented with touch file 2>&1 | logger but then decided that it is not worth the hassle.

kib marked an inline comment as done.

s/-i/-f/
Require var for rc script

This revision is now accepted and ready to land.May 5 2025, 11:21 AM
kevans added inline comments.
sbin/shutdown/shutdown.8
77
kib marked an inline comment as done.May 5 2025, 2:04 PM