ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/ptytty.C
(Generate patch)

Comparing rxvt-unicode/src/ptytty.C (file contents):
Revision 1.16 by root, Sun Aug 15 03:30:04 2004 UTC vs.
Revision 1.26 by root, Mon Jan 2 15:10:18 2006 UTC

46# include <sys/stropts.h> /* for I_PUSH */ 46# include <sys/stropts.h> /* for I_PUSH */
47#endif 47#endif
48#ifdef HAVE_ISASTREAM 48#ifdef HAVE_ISASTREAM
49# include <stropts.h> 49# include <stropts.h>
50#endif 50#endif
51#ifdef HAVE_PTY_H
52# include <pty.h>
53#endif
51 54
52#if defined( __FreeBSD__)
53// better do this via configure, but.... 55// better do this via configure, but....
56#if defined(__FreeBSD__)
54# include <libutil.h> 57# include <libutil.h>
58#elif defined(__DARWIN__) || (defined (__MACH__) && defined (__APPLE__))
59# include <util.h>
55#endif 60#endif
56 61
57#include <cstdio> 62#include <cstdio>
58#include <grp.h> 63#include <grp.h>
59 64
85 if (*ttydev != NULL) 90 if (*ttydev != NULL)
86 return pfd; 91 return pfd;
87#endif 92#endif
88 93
89#ifdef PTYS_ARE_GETPTY 94#ifdef PTYS_ARE_GETPTY
90
91 char *ptydev; 95 char *ptydev;
92 96
93 while ((ptydev = getpty ()) != NULL) 97 while ((ptydev = getpty ()) != NULL)
94 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0) 98 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0)
95 { 99 {
329} ttyconf; 333} ttyconf;
330 334
331void 335void
332rxvt_ptytty::privileges (rxvt_privaction action) 336rxvt_ptytty::privileges (rxvt_privaction action)
333{ 337{
338 if (!name || !*name)
339 return;
340
334 rxvt_privileges (RESTORE); 341 rxvt_privileges (RESTORE);
335 342
336 if (action == SAVE) 343 if (action == SAVE)
337 { 344 {
338 //next_tty_action = RESTORE;
339# ifndef RESET_TTY_TO_COMMON_DEFAULTS 345# ifndef RESET_TTY_TO_COMMON_DEFAULTS
340 /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ 346 /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */
341 if (lstat (name, &savestat) < 0) /* you lose out */ 347 if (lstat (name, &savestat) < 0) /* you lose out */
342 ;//next_tty_action = IGNORE; 348 ;
343 else 349 else
344# endif 350# endif
345
346 { 351 {
352 saved = true;
347 chown (name, getuid (), ttyconf.gid); /* fail silently */ 353 chown (name, getuid (), ttyconf.gid); /* fail silently */
348 chmod (name, ttyconf.mode); 354 chmod (name, ttyconf.mode);
349# ifdef HAVE_REVOKE 355# ifdef HAVE_REVOKE
350 revoke (name); 356 revoke (name);
351# endif 357# endif
352
353 } 358 }
354 } 359 }
355 else 360 else
356 { /* action == RESTORE */ 361 { /* action == RESTORE */
357 //next_tty_action = IGNORE;
358# ifndef RESET_TTY_TO_COMMON_DEFAULTS 362# ifndef RESET_TTY_TO_COMMON_DEFAULTS
363 if (saved)
364 {
359 chmod (name, savestat.st_mode); 365 chmod (name, savestat.st_mode);
360 chown (name, savestat.st_uid, savestat.st_gid); 366 chown (name, savestat.st_uid, savestat.st_gid);
367 }
361# else 368# else
362 chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); 369 chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
363 chown (name, 0, 0); 370 chown (name, 0, 0);
364# endif 371# endif
365 372
371 378
372rxvt_ptytty::rxvt_ptytty () 379rxvt_ptytty::rxvt_ptytty ()
373{ 380{
374 pty = tty = -1; 381 pty = tty = -1;
375 name = 0; 382 name = 0;
383#ifndef NO_SETOWNER_TTYDEV
384 saved = false;
385#endif
376} 386}
377 387
378rxvt_ptytty::~rxvt_ptytty () 388rxvt_ptytty::~rxvt_ptytty ()
379{ 389{
380 put (); 390 put ();
434 } 444 }
435 445
436 return true; 446 return true;
437} 447}
438 448
449void
450rxvt_ptytty::set_utf8_mode (bool on)
451{
452#ifdef IUTF8
453 if (pty != -1)
454 {
455 struct termios tio;
456
457 if (tcgetattr (pty, &tio) != -1)
458 {
459 tcflag_t new_cflag = tio.c_iflag;
460
461 if (on)
462 new_cflag |= IUTF8;
463 else
464 new_cflag &= ~IUTF8;
465
466 if (new_cflag != tio.c_iflag)
467 {
468 tio.c_iflag = new_cflag;
469 tcsetattr (pty, TCSANOW, &tio);
470 }
471 }
472 }
473#endif
474}
475
439/*----------------------- end-of-file (C source) -----------------------*/ 476/*----------------------- end-of-file (C source) -----------------------*/
440 477

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines