[comp.windows.x] Xterm vs 4.3BSD tty ownership

schwartz@shire.cs.psu.edu (Scott Schwartz) (01/26/89)

4.3BSD and related systems (e.g. SunOS 4.0) normally have active ttys
owned by group "tty".  Xterm does not currently provide for this
convention.  The following patch adds the necessary functionality;
I hope the good people at MIT will look it over and include it in
the standard xterm if they so choose.

This is diff-ed against 
	$XConsortium: main.c,v 1.99 88/01/04 14:33:47 jim Exp $

*** main.c.mit	Thu Jan 26 01:31:14 1989
--- main.c	Thu Jan 26 01:49:26 1989
***************
*** 1451,1461 ****
--- 1451,1479 ----
  			(void) strcpy(ttydev, ptr);
  		}
  
+ #ifdef USE_BSD43_TTY
+ 	{ 
+ #include <grp.h>
+ 		struct group *ttygrp;
+ 		if (ttygrp = getgrnam("tty")) {
+ 			/* change ownership of tty to real uid, "tty" gid */
+ 			chown (ttydev, screen->uid, ttygrp->gr_gid);
+ 		}
+ 		else {
+ 			/* change ownership of tty to real group and user id */
+ 			chown (ttydev, screen->uid, screen->gid);
+ 		}
+ 		endgrent();
+ 		/* change protection of tty */
+ 		chmod (ttydev, 0620);
+ 	}
+ #else
  		/* change ownership of tty to real group and user id */
  		chown (ttydev, screen->uid, screen->gid);
  
  		/* change protection of tty */
  		chmod (ttydev, 0622);
+ #endif USE_BSD43_TTY
  
  		if (!get_ty) {
  #ifdef USE_SYSV_TERMIO
-- 
Scott Schwartz		<schwartz@shire.cs.psu.edu>