--- rxvt-unicode/src/ptytty.C 2006/01/17 18:06:14 1.45 +++ rxvt-unicode/src/ptytty.C 2006/01/19 10:44:44 1.48 @@ -278,7 +278,7 @@ { setsid (); -# if defined(PTYS_ARE_PTMX) && defined(I_PUSH) +#if defined(PTYS_ARE_PTMX) && defined(I_PUSH) /* * Push STREAMS modules: * ptem: pseudo-terminal hardware emulation module. @@ -296,15 +296,15 @@ * close () - on the master side which causes a hang up to be sent * through - Geoff Wing */ -# ifdef HAVE_ISASTREAM +# ifdef HAVE_ISASTREAM if (isastream (fd_tty) == 1) -# endif +# endif { ioctl (fd_tty, I_PUSH, "ptem"); ioctl (fd_tty, I_PUSH, "ldterm"); ioctl (fd_tty, I_PUSH, "ttcompat"); } -# endif +#endif ioctl (fd_tty, TIOCSCTTY, NULL); @@ -381,7 +381,7 @@ #endif /* TTY_GID_SUPPORT */ { mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; - gid = getgid (); + gid = 0; } } } ttyconf; @@ -396,33 +396,16 @@ if (action == SAVE) { -# ifndef RESET_TTY_TO_COMMON_DEFAULTS - /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ - if (lstat (name, &savestat) < 0) /* you lose out */ - ; - else -# endif - { - saved = true; - chown (name, getuid (), ttyconf.gid); /* fail silently */ - chmod (name, ttyconf.mode); + chown (name, getuid (), ttyconf.gid); /* fail silently */ + chmod (name, ttyconf.mode); # ifdef HAVE_REVOKE - revoke (name); + revoke (name); # endif - } } else { /* action == RESTORE */ -# ifndef RESET_TTY_TO_COMMON_DEFAULTS - if (saved) - { - chmod (name, savestat.st_mode); - chown (name, savestat.st_uid, savestat.st_gid); - } -# else - chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); - chown (name, 0, 0); -# endif + chmod (name, RESTORE_TTY_MODE); + chown (name, 0, ttyconf.gid); } } #endif @@ -431,9 +414,6 @@ { pty = tty = -1; name = 0; -#ifndef NO_SETOWNER_TTYDEV - saved = false; -#endif #if UTMP_SUPPORT cmd_pid = 0; #endif @@ -638,14 +618,11 @@ } else { - setgid (getegid ()); - setuid (geteuid ()); - // server, pty-helper sock_fd = sv[1]; for (int fd = 0; fd < 1023; fd++) - if (fd != sock_fd && fd != 1) + if (fd != sock_fd) close (fd); serve ();