I thought it would be useful to have a sysctl for disabling the
keyboard reboot sequence.  This functionality is currently
available through the SC_DISABLE_REBOOT config option, but it's
convenient to have this capability available at runtime, too.

I can't say I'm much of a kernel hacker, but the attached patch
works fine for me.  It applies against 4.3-STABLE, but the same
logic applied to 5.0-CURRENT (which I don't have available for
testing).

Note that investigation revealed that OpenBSD has a similar
sysctl named machdep.kdbreset.  I prefer machdep.disable_reboot_key,
but I'm against changing it for feel-good compatibility reasons.

If someone with clue feels there is merit in this, feel free to
commit it.

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member
--- syscons.c.orig      Sun Oct 29 11:59:27 2000
+++ syscons.c   Mon May 21 12:15:57 2001
@@ -118,6 +118,12 @@
 SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
           0, "");
 
+#ifndef SC_DISABLE_REBOOT
+static int             disable_reboot_key;
+SYSCTL_INT(_machdep, OID_AUTO, disable_reboot_key, CTLFLAG_RW,
+          &disable_reboot_key, 0, "Disable the reboot key sequence");
+#endif
+
 #define SC_CONSOLECTL  255
 
 #define VIRTUAL_TTY(sc, x) (SC_DEV((sc), (x))->si_tty)
@@ -3101,19 +3107,22 @@
 
            case RBT:
 #ifndef SC_DISABLE_REBOOT
-               shutdown_nice(0);
+               if (!disable_reboot_key)
+                       shutdown_nice(0);
 #endif
                break;
 
            case HALT:
 #ifndef SC_DISABLE_REBOOT
-               shutdown_nice(RB_HALT);
+               if (!disable_reboot_key)
+                       shutdown_nice(RB_HALT);
 #endif
                break;
 
            case PDWN:
 #ifndef SC_DISABLE_REBOOT
-               shutdown_nice(RB_HALT|RB_POWEROFF);
+               if (!disable_reboot_key)
+                       shutdown_nice(RB_HALT|RB_POWEROFF);
 #endif
                break;
 

Reply via email to