From morettoni@libero.it  Fri Oct 15 10:59:39 2004
Return-Path: <morettoni@libero.it>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8079116A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Oct 2004 10:59:39 +0000 (GMT)
Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.127])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2BAA143D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Oct 2004 10:59:39 +0000 (GMT)
	(envelope-from morettoni@libero.it)
Received: from localhost (172.16.1.84) by smtp3.libero.it (7.0.027-DD01)
        id 4153CC0C004C1877 for FreeBSD-gnats-submit@freebsd.org; Fri, 15 Oct 2004 12:59:37 +0200
Received: from current.morettoni.local (151.44.88.220) by smtp20.libero.it (7.0.027-DD01)
        id 40E3F8E2041F2A85 for FreeBSD-gnats-submit@freebsd.org; Fri, 15 Oct 2004 12:59:37 +0200
Received: (qmail 1385 invoked by uid 0); 15 Oct 2004 11:00:05 -0000
Message-Id: <20041015110005.1384.qmail@current.morettoni.local>
Date: 15 Oct 2004 11:00:05 -0000
From: Luca Morettoni <morettoni@libero.it>
Reply-To: Luca Morettoni <morettoni@libero.it>
To: FreeBSD-gnats-submit@freebsd.org
Cc: phk@FreeBSD.org
Subject: [patch] keyboard debug and reboot qualification moved into sysctl
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         72728
>Category:       kern
>Synopsis:       [syscons] [patch] keyboard debug and reboot qualification moved into sysctl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brooks
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 15 11:00:45 GMT 2004
>Closed-Date:    Tue Feb 14 21:59:05 GMT 2006
>Last-Modified:  Tue Feb 14 21:59:05 GMT 2006
>Originator:     Luca Morettoni
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
Luca Morettoni
>Environment:
System: FreeBSD current.morettoni.local 6.0-CURRENT FreeBSD 6.0-CURRENT #33: Thu Oct 14 17:58:08 CEST 2004 luca@current.morettoni.local:/usr/obj/usr/src/sys/FRODO i386


	
>Description:
	This patch add to sysctl two new variables: hw.syscons.kbd_reboot and hw.syscons.kbd_debug
	The default value of this two are both 1, and that allow users to reboot and go into debug
	mode with keyboards shotcut. Setting them to 0 you can disable that at runtime.
	If you put SC_DISABLE_REBOOT and/or SC_DISABLE_KDBKEY in kernel config file that variables
	are set to 0 and you can't modify it.

>How-To-Repeat:
	
>Fix:

	Apply the following patch:

--- syscons.c.patch begins here ---
--- src/sys/dev/syscons/syscons.c.orig	Fri Oct 15 08:57:27 2004
+++ src/sys/dev/syscons/syscons.c	Thu Oct 14 17:06:23 2004
@@ -109,6 +109,19 @@
 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 */
+#else
+static  int		enable_reboot = FALSE;
+#endif
+
+#ifndef SC_DISABLE_KDBKEY
+static  int		enable_kdb = TRUE; /* enable keyboard debug */
+#else
+static  int		enable_kdb = FALSE;
+#endif
+
 static	long        	scrn_blank_time = 0;    /* screen saver timeout value */
 #ifdef DEV_SPLASH
 static	int     	scrn_blanked;		/* # of blanked screen */
@@ -124,6 +137,14 @@
     &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_kdb,
+    0, "enable keyboard debug");
+#endif
 #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT)
 #include "font.h"
 #endif
@@ -3267,21 +3288,15 @@
 		break;
 
 	    case RBT:
-#ifndef SC_DISABLE_REBOOT
-		shutdown_nice(0);
-#endif
+		if (enable_reboot) shutdown_nice(0);
 		break;
 
 	    case HALT:
-#ifndef SC_DISABLE_REBOOT
-		shutdown_nice(RB_HALT);
-#endif
+		if (enable_reboot) shutdown_nice(RB_HALT);
 		break;
 
 	    case PDWN:
-#ifndef SC_DISABLE_REBOOT
-		shutdown_nice(RB_HALT|RB_POWEROFF);
-#endif
+		if (enable_reboot) shutdown_nice(RB_HALT|RB_POWEROFF);
 		break;
 
 	    case SUSP:
@@ -3292,9 +3307,7 @@
 		break;
 
 	    case DBG:
-#ifndef SC_DISABLE_KDBKEY
-		kdb_enter("manual escape to debugger");
-#endif
+		if (enable_kdb) kdb_enter("manual escape to debugger");
 		break;
 
 	    case PNC:
--- syscons.c.patch ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brooks 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Mon Nov 1 20:00:15 GMT 2004 
Responsible-Changed-Why:  
This looks reasionable.  I'll take a better look at it soon. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72728 
State-Changed-From-To: open->patched 
State-Changed-By: brooks 
State-Changed-When: Sat Jan 14 17:58:17 UTC 2006 
State-Changed-Why:  
Finally committed to CURRENT.  Sorry for the delay. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72728 
State-Changed-From-To: patched->closed 
State-Changed-By: brooks 
State-Changed-When: Tue Feb 14 21:58:06 UTC 2006 
State-Changed-Why:  
Merged to RELENG_6.  No plans to merge to RELENG_5 due to 
lack of ability to test and impending EOL. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72728 
>Unformatted:
