Allow to disable some special key combinations handled by vt(4), like debug

request, reboot request.

Requested by:	Claude Buisson

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
ray 2014-08-03 13:07:25 +00:00
parent 211a74241c
commit dbbb1f8a83
3 changed files with 32 additions and 5 deletions

View File

@ -45,6 +45,7 @@ In
.Xr loader.conf 5 :
.Cd hw.vga.textmode=1
.Cd kern.vty=vt
.Cd kern.vt.spclkeys=15
.Sh DESCRIPTION
The
.Nm
@ -195,6 +196,19 @@ or
If this value is not set,
.Xr sc 4
is used.
.It Va kern.vt.spclkeys
bitmap of allowed special keys. 1 is enabled, 0 is disabled. Encoded as:
.Bl -tag -compact -width 0x000000
.It 0x0001
Debug request key combination. (Ctrl+Alt+Esc)
.It 0x0002
Reboot. (Ctrl+Alt+Del)
.It 0x0004
Halt.
.It 0x0008
Power down.
.El
Default is 15, all enabled.
.El
.Sh FILES
.Bl -tag -width /usr/share/syscons/keymaps/* -compact

View File

@ -87,6 +87,12 @@ static int vt_##_name = _default; \
SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\
_descr);
/* Allow to disable some special keys by users. */
#define VT_DEBUG_KEY_ENABLED (1 << 0)
#define VT_REBOOT_KEY_ENABLED (1 << 1)
#define VT_HALT_KEY_ENABLED (1 << 2)
#define VT_POWEROFF_KEY_ENABLED (1 << 3)
struct vt_driver;
void vt_allocate(struct vt_driver *, void *);

View File

@ -116,6 +116,9 @@ VT_SYSCTL_INT(enable_altgr, 1, "Enable AltGr key (Do not assume R.Alt as Alt)");
VT_SYSCTL_INT(debug, 0, "vt(9) debug level");
VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode");
VT_SYSCTL_INT(suspendswitch, 1, "Switch to VT0 before suspend");
VT_SYSCTL_INT(spclkeys, (VT_DEBUG_KEY_ENABLED|VT_REBOOT_KEY_ENABLED|
VT_HALT_KEY_ENABLED|VT_POWEROFF_KEY_ENABLED), "Enabled special keys "
"handled by vt(4)");
static struct vt_device vt_consdev;
static unsigned int vt_unit = 0;
@ -402,17 +405,21 @@ vt_machine_kbdevent(int c)
switch (c) {
case SPCLKEY | DBG:
kdb_enter(KDB_WHY_BREAK, "manual escape to debugger");
if (vt_spclkeys & VT_DEBUG_KEY_ENABLED)
kdb_enter(KDB_WHY_BREAK, "manual escape to debugger");
return (1);
case SPCLKEY | RBT:
/* XXX: Make this configurable! */
shutdown_nice(0);
if (vt_spclkeys & VT_REBOOT_KEY_ENABLED)
/* XXX: Make this configurable! */
shutdown_nice(0);
return (1);
case SPCLKEY | HALT:
shutdown_nice(RB_HALT);
if (vt_spclkeys & VT_HALT_KEY_ENABLED)
shutdown_nice(RB_HALT);
return (1);
case SPCLKEY | PDWN:
shutdown_nice(RB_HALT|RB_POWEROFF);
if (vt_spclkeys & VT_POWEROFF_KEY_ENABLED)
shutdown_nice(RB_HALT|RB_POWEROFF);
return (1);
};