[comp.windows.x] Small change to xterm

raj@limbo.UCI.EDU.UUCP (06/05/87)

We have about 10 Sun fileservers with lots of Sun 3/50's hanging off of each
one.  We cross mount all the areas containing users' files on every system
(including all diskless systems).  (This allows our users to simply log
into ANY Sun machine and have their files right there.)  Anyway, we had
complaints from a lot of users about the fact that whenever any fileserver
was brought down, they would get shutdown messages about it in all of their
windows!  I looked at the sources for xterm and found the #ifdef UTMP which
disables logging a user in /etc/utmp.  Not defining this code would take
care of the problem, however it would also remove all information about who's
logged in from where on *all* machines and we didn't like that.  Thus I added
yet another option to xterm!  By specifying "-wh" on the command line it avoids
writing an /etc/utmp entry and thus avoids wall messages in that window.
Here are the changes:

*** old_main.c	Mon Dec  8 06:30:54 1986
--- main.c	Thu Jun  4 13:19:31 1987
***************
*** 118,123 ****
--- 118,126 ----
  	"VisualBell",		/* DEF_VISUALBELL */
  	0,
  };
+ #ifdef	UTMP
+ static int	noutmp;
+ #endif	UTMP
  
  main (argc, argv)
  int argc;
***************
*** 139,144 ****
--- 142,150 ----
  	char *getenv();
  #endif KEYBD
  
+ #ifdef	UTMP
+ 	noutmp = FALSE;
+ #endif	UTMP
  	xterm_name = (strcmp(*argv, "-") == 0) ? "xterm" : basename(*argv);
  
  	term.flags = WRAPAROUND | SMOOTHSCROLL | AUTOREPEAT;
***************
*** 634,639 ****
--- 640,650 ----
  	     case ARG_VB:
  		screen->visualbell = i;
  		continue;
+ #ifdef	UTMP
+ 	     case ARG_WH:
+ 		noutmp = TRUE;
+ 		continue;
+ #endif	UTMP
  	     default:
  		Syntax ();
  	    }
***************
*** 786,791 ****
--- 797,803 ----
  	{"ti",	ARG_TI},
  	{"vb",	ARG_VB},
  	{"w",	ARG_BW},
+ 	{"wh",	ARG_WH},
  };
  
  argument(s)
***************
*** 823,829 ****
  #endif ARG_K
  " [-n name] [-nb bell_margin] [-po] [-ps] [-rv] [-rw] [-s] \\\n",
  " [-sb] [-si] [-sk] [-sl save_lines] [-sn] [-st] [-t] [-tb] \\\n",
! " [-ti] [-vb] [=[width]x[height][[+-]xoff[[+-]yoff]]] \\\n",
  " [%[width]x[height][[+-]xoff[[+-]yoff]]] [#[+-]xoff[[+-]yoff]] \\\n",
  " [-e command_to_exec]\n\n",
  "Fonts must be of fixed width and of same size;\n",
--- 835,841 ----
  #endif ARG_K
  " [-n name] [-nb bell_margin] [-po] [-ps] [-rv] [-rw] [-s] \\\n",
  " [-sb] [-si] [-sk] [-sl save_lines] [-sn] [-st] [-t] [-tb] \\\n",
! " [-ti] [-vb] [-wh] [=[width]x[height][[+-]xoff[[+-]yoff]]] \\\n",
  " [%[width]x[height][[+-]xoff[[+-]yoff]]] [#[+-]xoff[[+-]yoff]] \\\n",
  " [-e command_to_exec]\n\n",
  "Fonts must be of fixed width and of same size;\n",
***************
*** 854,859 ****
--- 866,872 ----
  "The -tb option disables the titlebar\n",
  "The -ti option places the window name under the icon\n",
  "The -vb option enables visual bell\n",
+ "The -wh option disables entering a /etc/utmp entry\n",
  0
  };
  
***************
*** 1190,1195 ****
--- 1203,1209 ----
  		if((tslot = ttyslot()) <= 0)
  			SysError(ERROR_TSLOT3);
  #ifdef UTMP
+ 		if(! noutmp)
  		if((pw = getpwuid(screen->uid)) &&
  		 (i = open(etc_utmp, O_WRONLY)) >= 0) {
  			bzero((char *)&utmp, sizeof(struct utmp));
***************
*** 1344,1350 ****
  	register int i;
  	struct utmp utmp;
  
! 	if(!am_slave && tslot > 0 && (i = open(etc_utmp, O_WRONLY)) >= 0) {
  		bzero((char *)&utmp, sizeof(struct utmp));
  		lseek(i, (long)(tslot * sizeof(struct utmp)), 0);
  		write(i, (char *)&utmp, sizeof(struct utmp));
--- 1358,1364 ----
  	register int i;
  	struct utmp utmp;
  
! 	if(!am_slave && tslot > 0 && !noutmp && (i = open(etc_utmp, O_WRONLY)) >= 0) {
  		bzero((char *)&utmp, sizeof(struct utmp));
  		lseek(i, (long)(tslot * sizeof(struct utmp)), 0);
  		write(i, (char *)&utmp, sizeof(struct utmp));


*** old_main.h	Mon Dec  1 17:11:24 1986
--- main.h	Thu Jun  4 11:28:31 1987
***************
*** 122,127 ****
--- 122,128 ----
  #define	ARG_TB			(ARG_T+1)
  #define	ARG_TI			(ARG_TB+1)
  #define	ARG_VB			(ARG_TI+1)
+ #define	ARG_WH			(ARG_VB+1)
  
  #define	DEFBOLDFONT		"vtbold"
  #define	DEFBORDER		1


-----------------------------------------------------------------------------
Richard A. Johnson                              raj@rome.uci.edu   (Internet)
UCI ICS Assistant Technical Manager              ucbvax!ucivax!raj     (UUCP)
Postmaster / Network Services             raj@limbo.uci.edu (via Nameservers)

leres@ucbarpa.Berkeley.EDU.UUCP (06/05/87)

The "standard" version of wall writes to all tty's that have utmp
entries. The Sun version is hacked so that it ignores pty's that don't
have anything in the host field. So instead of adding a flag to
completely skip the utmp code, I just added a simple test in main.c:

+       if (strcmp("unix:0", DisplayName()) != 0)
	    (void) strcpy(utmp.ut_host, DisplayName());

(I never liked having "unix:0" in the utmp anyway; it was nice to find
a legitimate reason for nuking it.)

		Craig