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.18 by root, Sun Dec 12 05:54:05 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// better do this via configure, but.... 55// better do this via configure, but....
53#if defined(__FreeBSD__) 56#if defined(__FreeBSD__)
54# include <libutil.h> 57# include <libutil.h>
55#elif defined(__DARWIN__) || (defined (__MACH__) && defined (__APPLE__)) 58#elif defined(__DARWIN__) || (defined (__MACH__) && defined (__APPLE__))
87 if (*ttydev != NULL) 90 if (*ttydev != NULL)
88 return pfd; 91 return pfd;
89#endif 92#endif
90 93
91#ifdef PTYS_ARE_GETPTY 94#ifdef PTYS_ARE_GETPTY
92
93 char *ptydev; 95 char *ptydev;
94 96
95 while ((ptydev = getpty ()) != NULL) 97 while ((ptydev = getpty ()) != NULL)
96 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0) 98 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0)
97 { 99 {
331} ttyconf; 333} ttyconf;
332 334
333void 335void
334rxvt_ptytty::privileges (rxvt_privaction action) 336rxvt_ptytty::privileges (rxvt_privaction action)
335{ 337{
338 if (!name || !*name)
339 return;
340
336 rxvt_privileges (RESTORE); 341 rxvt_privileges (RESTORE);
337 342
338 if (action == SAVE) 343 if (action == SAVE)
339 { 344 {
340 //next_tty_action = RESTORE;
341# ifndef RESET_TTY_TO_COMMON_DEFAULTS 345# ifndef RESET_TTY_TO_COMMON_DEFAULTS
342 /* 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 */
343 if (lstat (name, &savestat) < 0) /* you lose out */ 347 if (lstat (name, &savestat) < 0) /* you lose out */
344 ;//next_tty_action = IGNORE; 348 ;
345 else 349 else
346# endif 350# endif
347
348 { 351 {
352 saved = true;
349 chown (name, getuid (), ttyconf.gid); /* fail silently */ 353 chown (name, getuid (), ttyconf.gid); /* fail silently */
350 chmod (name, ttyconf.mode); 354 chmod (name, ttyconf.mode);
351# ifdef HAVE_REVOKE 355# ifdef HAVE_REVOKE
352 revoke (name); 356 revoke (name);
353# endif 357# endif
354
355 } 358 }
356 } 359 }
357 else 360 else
358 { /* action == RESTORE */ 361 { /* action == RESTORE */
359 //next_tty_action = IGNORE;
360# ifndef RESET_TTY_TO_COMMON_DEFAULTS 362# ifndef RESET_TTY_TO_COMMON_DEFAULTS
363 if (saved)
364 {
361 chmod (name, savestat.st_mode); 365 chmod (name, savestat.st_mode);
362 chown (name, savestat.st_uid, savestat.st_gid); 366 chown (name, savestat.st_uid, savestat.st_gid);
367 }
363# else 368# else
364 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));
365 chown (name, 0, 0); 370 chown (name, 0, 0);
366# endif 371# endif
367 372
373 378
374rxvt_ptytty::rxvt_ptytty () 379rxvt_ptytty::rxvt_ptytty ()
375{ 380{
376 pty = tty = -1; 381 pty = tty = -1;
377 name = 0; 382 name = 0;
383#ifndef NO_SETOWNER_TTYDEV
384 saved = false;
385#endif
378} 386}
379 387
380rxvt_ptytty::~rxvt_ptytty () 388rxvt_ptytty::~rxvt_ptytty ()
381{ 389{
382 put (); 390 put ();
436 } 444 }
437 445
438 return true; 446 return true;
439} 447}
440 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
441/*----------------------- end-of-file (C source) -----------------------*/ 476/*----------------------- end-of-file (C source) -----------------------*/
442 477

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines