[comp.windows.x] Sun security problem; xterm grabbing console.

brsmith@umn-cs.CS.UMN.EDU (Brian R. Smith) (08/28/89)

(I read comp.windows.x (aka xpert) only when I have time; forgive me
 if I've missed a discussion of this before.)

We just got two GraphOn's and connected them to our Sun fileserver
(which was mostly idle) and instantly had a problem.  Everyone had
an "xterm -C" as one of their windows, which is nice when you login
on one of the clients, as it keeps console output from messing up
your screen.  On the server, though, it would lock up the console
terminal, preventing anyone from logging in there.

Here's a four-line hack to fix it.  It will only allow -C if you're
already logged in on console.  I've only tested it on our Sun-2 systems,
but it should work on any 4.2 (or 4.3) machine.  (Of course, the only
machines that need it are those that support TIOCCONS...)

Brian
brsmith@umn-cs.cs.umn.edu
------------------------------------------------------------------------
*** main.c.orig	Fri Feb  3 21:35:13 1989
--- main.c	Sun Aug 27 16:18:53 1989
***************
*** 252,258
  static int loginpty;
  
  #ifdef TIOCCONS
! static int Console;
  #endif	/* TIOCCONS */
  #ifndef USE_SYSV_UTMP
  static int tslot;

--- 252,258 -----
  static int loginpty;
  
  #ifdef TIOCCONS
! static int Console = FALSE;   /* No functional change, but looks nicer. */
  #endif	/* TIOCCONS */
  #ifndef USE_SYSV_UTMP
  static int tslot;
***************
*** 688,694
  		/* NOTREACHED */
  #ifdef TIOCCONS
  	     case 'C':
! 		Console = TRUE;
  		continue;
  #endif	/* TIOCCONS */
  	     case 'L':

--- 688,697 -----
  		/* NOTREACHED */
  #ifdef TIOCCONS
  	     case 'C':
! 		if (access("/dev/console", R_OK | W_OK) == 0)
! 		  {
! 		    Console = TRUE;
! 		  }
  		continue;
  #endif	/* TIOCCONS */