From owner-freebsd-hackers Mon May 21 9:31: 2 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mcp.csh.rit.edu (mcp.csh.rit.edu [129.21.60.9]) by hub.freebsd.org (Postfix) with ESMTP id 96F8937B42C for ; Mon, 21 May 2001 09:30:57 -0700 (PDT) (envelope-from jon@csh.rit.edu) Received: from fury.csh.rit.edu (fury.csh.rit.edu [129.21.60.5]) by mcp.csh.rit.edu (Postfix) with ESMTP id 2ADA411FD for ; Mon, 21 May 2001 12:30:45 -0400 (EDT) Received: by fury.csh.rit.edu (Postfix, from userid 37404) id B3AE72E3E5; Mon, 21 May 2001 12:30:44 -0400 (EDT) Date: Mon, 21 May 2001 12:30:44 -0400 From: Jon Parise To: freebsd-hackers@freebsd.org Subject: sysctl to disable reboot Message-ID: <20010521123044.H29180@csh.rit.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline User-Agent: Mutt/1.3.12i X-Operating-System: SunOS 5.8 (sun4u) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 (jon@csh.rit.edu) . Rochester Inst. of Technology http://www.csh.rit.edu/~jon/ : Computer Science House Member --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="disable_reboot.patch" --- 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; --EVF5PPMfhYS0aIcm-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message