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.22 by root, Tue Jan 11 04:44:57 2005 UTC vs.
Revision 1.27 by root, Tue Jan 3 16:32:33 2006 UTC

76 int pfd; 76 int pfd;
77 77
78#ifdef PTYS_ARE_OPENPTY 78#ifdef PTYS_ARE_OPENPTY
79 char tty_name[sizeof "/dev/pts/????\0"]; 79 char tty_name[sizeof "/dev/pts/????\0"];
80 80
81 rxvt_privileges(RESTORE);
81 if (openpty (&pfd, fd_tty, tty_name, NULL, NULL) != -1) 82 int res = openpty (&pfd, fd_tty, tty_name, NULL, NULL);
83 rxvt_privileges(IGNORE);
84
85 if (res != -1)
82 { 86 {
83 *ttydev = strdup (tty_name); 87 *ttydev = strdup (tty_name);
84 return pfd; 88 return pfd;
85 } 89 }
86#endif 90#endif
90 if (*ttydev != NULL) 94 if (*ttydev != NULL)
91 return pfd; 95 return pfd;
92#endif 96#endif
93 97
94#ifdef PTYS_ARE_GETPTY 98#ifdef PTYS_ARE_GETPTY
95
96 char *ptydev; 99 char *ptydev;
97 100
98 while ((ptydev = getpty ()) != NULL) 101 while ((ptydev = getpty ()) != NULL)
99 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0) 102 if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0)
100 { 103 {
334} ttyconf; 337} ttyconf;
335 338
336void 339void
337rxvt_ptytty::privileges (rxvt_privaction action) 340rxvt_ptytty::privileges (rxvt_privaction action)
338{ 341{
342 if (!name || !*name)
343 return;
344
339 rxvt_privileges (RESTORE); 345 rxvt_privileges (RESTORE);
340 346
341 if (action == SAVE) 347 if (action == SAVE)
342 { 348 {
343 //next_tty_action = RESTORE;
344# ifndef RESET_TTY_TO_COMMON_DEFAULTS 349# ifndef RESET_TTY_TO_COMMON_DEFAULTS
345 /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ 350 /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */
346 if (lstat (name, &savestat) < 0) /* you lose out */ 351 if (lstat (name, &savestat) < 0) /* you lose out */
347 ;//next_tty_action = IGNORE; 352 ;
348 else 353 else
349# endif 354# endif
350
351 { 355 {
356 saved = true;
352 chown (name, getuid (), ttyconf.gid); /* fail silently */ 357 chown (name, getuid (), ttyconf.gid); /* fail silently */
353 chmod (name, ttyconf.mode); 358 chmod (name, ttyconf.mode);
354# ifdef HAVE_REVOKE 359# ifdef HAVE_REVOKE
355 revoke (name); 360 revoke (name);
356# endif 361# endif
357
358 } 362 }
359 } 363 }
360 else 364 else
361 { /* action == RESTORE */ 365 { /* action == RESTORE */
362 //next_tty_action = IGNORE;
363# ifndef RESET_TTY_TO_COMMON_DEFAULTS 366# ifndef RESET_TTY_TO_COMMON_DEFAULTS
367 if (saved)
368 {
364 chmod (name, savestat.st_mode); 369 chmod (name, savestat.st_mode);
365 chown (name, savestat.st_uid, savestat.st_gid); 370 chown (name, savestat.st_uid, savestat.st_gid);
371 }
366# else 372# else
367 chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); 373 chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
368 chown (name, 0, 0); 374 chown (name, 0, 0);
369# endif 375# endif
370 376
376 382
377rxvt_ptytty::rxvt_ptytty () 383rxvt_ptytty::rxvt_ptytty ()
378{ 384{
379 pty = tty = -1; 385 pty = tty = -1;
380 name = 0; 386 name = 0;
387#ifndef NO_SETOWNER_TTYDEV
388 saved = false;
389#endif
381} 390}
382 391
383rxvt_ptytty::~rxvt_ptytty () 392rxvt_ptytty::~rxvt_ptytty ()
384{ 393{
385 put (); 394 put ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines