… | |
… | |
90 | if (*ttydev != NULL) |
90 | if (*ttydev != NULL) |
91 | return pfd; |
91 | return pfd; |
92 | #endif |
92 | #endif |
93 | |
93 | |
94 | #ifdef PTYS_ARE_GETPTY |
94 | #ifdef PTYS_ARE_GETPTY |
95 | |
|
|
96 | char *ptydev; |
95 | char *ptydev; |
97 | |
96 | |
98 | while ((ptydev = getpty ()) != NULL) |
97 | while ((ptydev = getpty ()) != NULL) |
99 | if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0) |
98 | if ((pfd = open (ptydev, O_RDWR | O_NOCTTY, 0)) >= 0) |
100 | { |
99 | { |
… | |
… | |
334 | } ttyconf; |
333 | } ttyconf; |
335 | |
334 | |
336 | void |
335 | void |
337 | rxvt_ptytty::privileges (rxvt_privaction action) |
336 | rxvt_ptytty::privileges (rxvt_privaction action) |
338 | { |
337 | { |
|
|
338 | if (!name || !*name) |
|
|
339 | return; |
|
|
340 | |
339 | rxvt_privileges (RESTORE); |
341 | rxvt_privileges (RESTORE); |
340 | |
342 | |
341 | if (action == SAVE) |
343 | if (action == SAVE) |
342 | { |
344 | { |
343 | //next_tty_action = RESTORE; |
|
|
344 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
345 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
345 | /* 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 */ |
346 | if (lstat (name, &savestat) < 0) /* you lose out */ |
347 | if (lstat (name, &savestat) < 0) /* you lose out */ |
347 | ;//next_tty_action = IGNORE; |
348 | ; |
348 | else |
349 | else |
349 | # endif |
350 | # endif |
350 | |
|
|
351 | { |
351 | { |
|
|
352 | saved = true; |
352 | chown (name, getuid (), ttyconf.gid); /* fail silently */ |
353 | chown (name, getuid (), ttyconf.gid); /* fail silently */ |
353 | chmod (name, ttyconf.mode); |
354 | chmod (name, ttyconf.mode); |
354 | # ifdef HAVE_REVOKE |
355 | # ifdef HAVE_REVOKE |
355 | revoke (name); |
356 | revoke (name); |
356 | # endif |
357 | # endif |
357 | |
|
|
358 | } |
358 | } |
359 | } |
359 | } |
360 | else |
360 | else |
361 | { /* action == RESTORE */ |
361 | { /* action == RESTORE */ |
362 | //next_tty_action = IGNORE; |
|
|
363 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
362 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
|
|
363 | if (saved) |
|
|
364 | { |
364 | chmod (name, savestat.st_mode); |
365 | chmod (name, savestat.st_mode); |
365 | chown (name, savestat.st_uid, savestat.st_gid); |
366 | chown (name, savestat.st_uid, savestat.st_gid); |
|
|
367 | } |
366 | # else |
368 | # else |
367 | 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)); |
368 | chown (name, 0, 0); |
370 | chown (name, 0, 0); |
369 | # endif |
371 | # endif |
370 | |
372 | |
… | |
… | |
376 | |
378 | |
377 | rxvt_ptytty::rxvt_ptytty () |
379 | rxvt_ptytty::rxvt_ptytty () |
378 | { |
380 | { |
379 | pty = tty = -1; |
381 | pty = tty = -1; |
380 | name = 0; |
382 | name = 0; |
|
|
383 | #ifndef NO_SETOWNER_TTYDEV |
|
|
384 | saved = false; |
|
|
385 | #endif |
381 | } |
386 | } |
382 | |
387 | |
383 | rxvt_ptytty::~rxvt_ptytty () |
388 | rxvt_ptytty::~rxvt_ptytty () |
384 | { |
389 | { |
385 | put (); |
390 | put (); |