Skip to contentSkip to conversation

Restrict VT-Switching per VT

PATCH New Thomas Warwaris 1 participant 1 message May 5, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Restrict VT-Switching per VT

Linus,

this patch on 2.4.4 adds the ability to turn VT-switching on and off for each (existing) VT via ioctl().

It works exactly like the existing code by blocking VT-switching to the blocked terminals.

It is a very nice feature to 'hide' VT's of users allowing others to work with other VT's on the same machine.

I am not on the kernel list. Pleas CC me followups to [email protected]

BTW: Thank you all for your work.

Thomas

include/linux/vt.h +2 -0
diff -urN -X dontdiff linux-2.4.4.ori/include/linux/vt.h linux/include/linux/vt.h
@@ -50,5 +50,7 @@
 #define VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
 #define VT_LOCKSWITCH   0x560B  /* disallow vt switching */
 #define VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
+#define VT_LOCKSWITCHTO 	0x560D  /* disallow vt switching to a vt*/
+#define VT_UNLOCKSWITCHTO 	0x560E  /* allow vt switching to a vt*/
 
 #endif /* _LINUX_VT_H */
drivers/char/vt.c +14 -0
diff -urN -X dontdiff linux-2.4.4.ori/drivers/char/vt.c linux/drivers/char/vt.c
@@ -7,6 +7,7 @@
  *  Dynamic keymap and string allocation - [email protected] - May 1994
  *  Restrict VT switching via ioctl() - [email protected] - Dec 1995
  *  Some code moved for less code duplication - Andi Kleen - Mar 1997
+ *  Restrict VT switching per VT - Thomas Warwaris - May 2001
  */
 
 #include <linux/config.h>
@@ -41,6 +42,7 @@
 #endif /* CONFIG_FB_COMPAT_XPMAC */
 
 char vt_dont_switch;
+char vt_dont_switch_to [MAX_NR_CONSOLES];
 extern struct tty_driver console_driver;
 
 #define VT_IS_IN_USE(i)	(console_driver.table[i] && console_driver.table[i]->count)
@@ -1047,6 +1049,16 @@
 		   return -EPERM;
 		vt_dont_switch = 0;
 		return 0;
+	case VT_LOCKSWITCHTO:
+		if (!suser())
+			return -EPERM;
+		vt_dont_switch_to[arg-1] = 1;
+		return 0;
+	case VT_UNLOCKSWITCHTO:
+		if (!suser())
+			return -EPERM;
+		vt_dont_switch_to[arg-1] = 0;
+		return 0;
 #ifdef CONFIG_FB_COMPAT_XPMAC
 	case VC_GETMODE:
 		{
@@ -1243,6 +1255,8 @@
 void change_console(unsigned int new_console)
 {
         if ((new_console == fg_console) || (vt_dont_switch))
+                return;
+        if ( vt_dont_switch_to[new_console] )
                 return;
         if (!vc_cons_allocated(new_console))
 		return;