… | |
… | |
379 | } |
379 | } |
380 | else |
380 | else |
381 | #endif /* TTY_GID_SUPPORT */ |
381 | #endif /* TTY_GID_SUPPORT */ |
382 | { |
382 | { |
383 | mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; |
383 | mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; |
384 | gid = getgid (); |
384 | gid = 0; |
385 | } |
385 | } |
386 | } |
386 | } |
387 | } ttyconf; |
387 | } ttyconf; |
388 | |
388 | |
389 | ///////////////////////////////////////////////////////////////////////////// |
389 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
394 | if (!name || !*name) |
394 | if (!name || !*name) |
395 | return; |
395 | return; |
396 | |
396 | |
397 | if (action == SAVE) |
397 | if (action == SAVE) |
398 | { |
398 | { |
399 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
399 | chown (name, getuid (), ttyconf.gid); /* fail silently */ |
400 | /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ |
400 | chmod (name, ttyconf.mode); |
401 | if (lstat (name, &savestat) < 0) /* you lose out */ |
401 | # ifdef HAVE_REVOKE |
402 | ; |
402 | revoke (name); |
403 | else |
|
|
404 | # endif |
403 | # endif |
405 | { |
|
|
406 | saved = true; |
|
|
407 | chown (name, getuid (), ttyconf.gid); /* fail silently */ |
|
|
408 | chmod (name, ttyconf.mode); |
|
|
409 | # ifdef HAVE_REVOKE |
|
|
410 | revoke (name); |
|
|
411 | # endif |
|
|
412 | } |
|
|
413 | } |
404 | } |
414 | else |
405 | else |
415 | { /* action == RESTORE */ |
406 | { /* action == RESTORE */ |
416 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
407 | chmod (name, RESTORE_TTY_MODE); |
417 | if (saved) |
|
|
418 | { |
|
|
419 | chmod (name, savestat.st_mode); |
|
|
420 | chown (name, savestat.st_uid, savestat.st_gid); |
|
|
421 | } |
|
|
422 | # else |
|
|
423 | chmod (name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); |
|
|
424 | chown (name, 0, 0); |
408 | chown (name, 0, ttyconf.gid); |
425 | # endif |
|
|
426 | } |
409 | } |
427 | } |
410 | } |
428 | #endif |
411 | #endif |
429 | |
412 | |
430 | rxvt_ptytty_unix::rxvt_ptytty_unix () |
413 | rxvt_ptytty_unix::rxvt_ptytty_unix () |
431 | { |
414 | { |
432 | pty = tty = -1; |
415 | pty = tty = -1; |
433 | name = 0; |
416 | name = 0; |
434 | #ifndef NO_SETOWNER_TTYDEV |
|
|
435 | saved = false; |
|
|
436 | #endif |
|
|
437 | #if UTMP_SUPPORT |
417 | #if UTMP_SUPPORT |
438 | cmd_pid = 0; |
418 | cmd_pid = 0; |
439 | #endif |
419 | #endif |
440 | } |
420 | } |
441 | |
421 | |