valdis@SUN.MCS.CLARKSON.EDU (03/08/89)
I have enclosed a small patch to xterm/main.c which makes xterm follow the BSD 4.3 conventions that a /dev/ttyxx is group 'tty' and all programs that scribble on the tube (talk, write, and so forth) are set-GID 'tty'. Note that this patch ONLY applies to BSD 4.3 derived systems that use this convention, it will break things on other boxes that expect that a tty is world-writeable to send a message. Caveats: I've been using this on a net of Sun 3's running SunOS 4.0.1. Your mileage may vary... Valdis Kletnieks Sr. Systems Programmer Clarkson University Context diff follows... *** main.c.old Thu Feb 23 10:55:12 1989 --- main.c Thu Feb 23 15:15:45 1989 *************** *** 120,125 **** --- 120,129 ---- #define WTMP_FILENAME "/usr/adm/wtmp" #endif #endif + /* V. Kletnieks - include header for getgrent */ + #ifndef TTYNOGROUP + #include <grp.h> + #endif #include "ptyx.h" #include "data.h" *************** *** 1450,1461 **** ttydev = realloc (ttydev, (unsigned) (strlen(ptr) + 1)); (void) strcpy(ttydev, ptr); } ! /* change ownership of tty to real group and user id */ chown (ttydev, screen->uid, screen->gid); /* change protection of tty */ chmod (ttydev, 0622); if (!get_ty) { #ifdef USE_SYSV_TERMIO --- 1454,1475 ---- ttydev = realloc (ttydev, (unsigned) (strlen(ptr) + 1)); (void) strcpy(ttydev, ptr); } ! #ifdef TTYNOGROUP /* change ownership of tty to real group and user id */ chown (ttydev, screen->uid, screen->gid); /* change protection of tty */ chmod (ttydev, 0622); + #else + /* change ownership of tty to real userid, group 'tty' */ + /* Note that we never save the group entry, just the gid */ + setgrent(); + chown (ttydev, screen->uid, (getgrnam("tty"))->gr_gid); + endgrent(); + + /* change protection of tty */ + chmod (ttydev, 0620); + #endif /* TTYNOGROUP */ if (!get_ty) { #ifdef USE_SYSV_TERMIO