--- rxvt-unicode/src/ptytty.C 2004/08/15 03:30:04 1.16 +++ rxvt-unicode/src/ptytty.C 2005/12/31 16:06:48 1.24 @@ -48,10 +48,15 @@ #ifdef HAVE_ISASTREAM # include #endif +#ifdef HAVE_PTY_H +# include +#endif -#if defined( __FreeBSD__) // better do this via configure, but.... +#if defined(__FreeBSD__) # include +#elif defined(__DARWIN__) || (defined (__MACH__) && defined (__APPLE__)) +# include #endif #include @@ -71,9 +76,13 @@ int pfd; #ifdef PTYS_ARE_OPENPTY - char tty_name[sizeof "/dev/pts/????\0"]; + char tty_name[sizeof "/dev/pts/?????\0"]; - if (openpty (&pfd, fd_tty, tty_name, NULL, NULL) != -1) + rxvt_privileges (RESTORE); + int res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); + rxvt_privileges (IGNORE); + + if (res != -1) { *ttydev = strdup (tty_name); return pfd; @@ -331,6 +340,9 @@ void rxvt_ptytty::privileges (rxvt_privaction action) { + if (tty < 0) + return; + rxvt_privileges (RESTORE); if (action == SAVE) @@ -342,14 +354,12 @@ ;//next_tty_action = IGNORE; else # endif - { chown (name, getuid (), ttyconf.gid); /* fail silently */ chmod (name, ttyconf.mode); # ifdef HAVE_REVOKE revoke (name); # endif - } } else @@ -436,5 +446,32 @@ return true; } +void +rxvt_ptytty::set_utf8_mode (bool on) +{ +#ifdef IUTF8 + if (pty != -1) + { + struct termios tio; + + if (tcgetattr (pty, &tio) != -1) + { + tcflag_t new_cflag = tio.c_iflag; + + if (on) + new_cflag |= IUTF8; + else + new_cflag &= ~IUTF8; + + if (new_cflag != tio.c_iflag) + { + tio.c_iflag = new_cflag; + tcsetattr (pty, TCSANOW, &tio); + } + } + } +#endif +} + /*----------------------- end-of-file (C source) -----------------------*/