From 30e3426947c6d29e951b633195b9c8c6a165b054 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Sat, 14 Jan 2006 17:57:17 +0000 Subject: [PATCH] When SC_DISABLE_KDBKEY or SC_DISABLE_REBOOT are not defined allow the same behavior to be controlled by the sysctls, hw.syscons.kbd_kbdkey and hw.syscons.kbd_reboot respectively. Apologies to the submitter for taking so long to commit this simple change. PR: kern/72728 Submitted by: Luca Morettoni MFC After: 3 days --- share/man/man4/syscons.4 | 10 ++++++++++ sys/dev/syscons/syscons.c | 29 +++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/share/man/man4/syscons.4 b/share/man/man4/syscons.4 index 974ca9bbd309..63835e67bf0f 100644 --- a/share/man/man4/syscons.4 +++ b/share/man/man4/syscons.4 @@ -288,10 +288,20 @@ It will prevent users from entering the kernel debugger (KDB) by pressing the key combination. KDB will still be invoked when the kernel panics or hits a break point if it is included in the kernel. +If this option is not defined, this behavior may be controled at runtime +by the +.Xr sysctl 8 +variable +.Pq Va hw.syscons.kbd_kbdkey . .It Dv SC_DISABLE_REBOOT This option disables the ``reboot'' key (by default, it is .Dv Ctl-Alt-Del ) , so that the casual user may not accidentally reboot the system. +If this option is not defined, this behavior may be controled at runtime +by the +.Xr sysctl 8 +variable +.Pq Va hw.syscons.kbd_reboot . .It Dv SC_HISTORY_SIZE=N Sets the size of back scroll buffer to .Fa N diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index d7a5b14f8c55..e1228d4221ae 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -112,6 +112,15 @@ static char sc_malloc = FALSE; static int saver_mode = CONS_NO_SAVER; /* LKM/user saver */ static int run_scrn_saver = FALSE; /* should run the saver? */ static int enable_bell = TRUE; /* enable beeper */ + +#ifndef SC_DISABLE_REBOOT +static int enable_reboot = TRUE; /* enable keyboard reboot */ +#endif + +#ifndef SC_DISABLE_KDBKEY +static int enable_kdbkey = TRUE; /* enable keyboard debug */ +#endif + static long scrn_blank_time = 0; /* screen saver timeout value */ #ifdef DEV_SPLASH static int scrn_blanked; /* # of blanked screen */ @@ -127,6 +136,14 @@ SYSCTL_INT(_hw_syscons_saver, OID_AUTO, keybonly, CTLFLAG_RW, &sc_saver_keyb_only, 0, "screen saver interrupted by input only"); SYSCTL_INT(_hw_syscons, OID_AUTO, bell, CTLFLAG_RW, &enable_bell, 0, "enable bell"); +#ifndef SC_DISABLE_REBOOT +SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable_reboot, + 0, "enable keyboard reboot"); +#endif +#ifndef SC_DISABLE_KDBKEY +SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey, + 0, "enable keyboard debug"); +#endif #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT) #include "font.h" #endif @@ -3274,19 +3291,22 @@ scgetc(sc_softc_t *sc, u_int flags) case RBT: #ifndef SC_DISABLE_REBOOT - shutdown_nice(0); + if (enable_reboot) + shutdown_nice(0); #endif break; case HALT: #ifndef SC_DISABLE_REBOOT - shutdown_nice(RB_HALT); + if (enable_reboot) + shutdown_nice(RB_HALT); #endif break; case PDWN: #ifndef SC_DISABLE_REBOOT - shutdown_nice(RB_HALT|RB_POWEROFF); + if (enable_reboot) + shutdown_nice(RB_HALT|RB_POWEROFF); #endif break; @@ -3299,7 +3319,8 @@ scgetc(sc_softc_t *sc, u_int flags) case DBG: #ifndef SC_DISABLE_KDBKEY - kdb_enter("manual escape to debugger"); + if (enable_kdbkey) + kdb_enter("manual escape to debugger"); #endif break;