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

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.182 by root, Tue Jan 17 10:14:26 2006 UTC vs.
Revision 1.186 by root, Tue Jan 17 15:41:33 2006 UTC

209void rxvt_term::emergency_cleanup () 209void rxvt_term::emergency_cleanup ()
210{ 210{
211 if (cmd_pid) 211 if (cmd_pid)
212 kill (-cmd_pid, SIGHUP); 212 kill (-cmd_pid, SIGHUP);
213 213
214#ifdef UTMP_SUPPORT 214 delete pty; pty = 0;
215 privileged_utmp (RESTORE);
216#endif
217
218 pty.put ();
219} 215}
220 216
221rxvt_term::~rxvt_term () 217rxvt_term::~rxvt_term ()
222{ 218{
223 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)); 219 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END));
509 rxvt_perl.init (this); 505 rxvt_perl.init (this);
510 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 506 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
511 } 507 }
512#endif 508#endif
513 509
510 pty = rxvt_new_ptytty ();
511
514 create_windows (argc, argv); 512 create_windows (argc, argv);
515 513
516 dDisp; 514 dDisp;
517 515
518 init_xlocale (); 516 init_xlocale ();
543 541
544 init_command (cmd_argv); 542 init_command (cmd_argv);
545 543
546 free (cmd_argv); 544 free (cmd_argv);
547 545
548 if (pty.pty >= 0) 546 if (pty->pty >= 0)
549 pty_ev.start (pty.pty, EVENT_READ); 547 pty_ev.start (pty->pty, EVENT_READ);
550 548
551 check_ev.start (); 549 check_ev.start ();
552 550
553 HOOK_INVOKE ((this, HOOK_START, DT_END)); 551 HOOK_INVOKE ((this, HOOK_START, DT_END));
554 552
598char **rxvt_environ; // startup environment 596char **rxvt_environ; // startup environment
599 597
600void 598void
601rxvt_init () 599rxvt_init ()
602{ 600{
601 uid_t uid = getuid ();
602 gid_t gid = getgid ();
603
604 // before doing anything else, check for setuid/setgid operation,
605 // start the helper process and drop privileges
606 if (uid != geteuid ()
607 || 1 //D
608 || gid != getegid ())
609 {
610#if PTYTTY_HELPER
611 rxvt_ptytty_server ();
612#else
613 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
614#endif
615
616 // drop privileges
617#if HAVE_SETRESUID
618 setresgid (gid, gid, gid);
619 setresuid (uid, uid, uid);
620#elif HAVE_SETREUID
621 setregid (gid, gid);
622 setreuid (uid, uid);
623#elif HAVE_SETUID
624 setgid (gid);
625 setuid (uid);
626#endif
627
628 if (uid != geteuid ()
629 || gid != getegid ())
630 rxvt_fatal ("unable to drop privileges, aborting.\n");
631 }
632
603 rxvt_environ = environ; 633 rxvt_environ = environ;
604 634
605 /* 635 /*
606 * Save and then give up any super-user privileges 636 * Save and then give up any super-user privileges
607 * If we need privileges in any area then we must specifically request it. 637 * If we need privileges in any area then we must specifically request it.
713 } 743 }
714# endif 744# endif
715#endif 745#endif
716} 746}
717 747
718#ifdef UTMP_SUPPORT
719void
720rxvt_term::privileged_utmp (rxvt_privaction action)
721{
722 if (OPTION (Opt_utmpInhibit)
723 || !pty.name || !*pty.name)
724 return;
725
726 rxvt_privileges (RESTORE);
727
728 if (action == SAVE)
729 pty.login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]);
730 else
731 pty.logout ();
732
733 rxvt_privileges (IGNORE);
734}
735#endif
736
737/*----------------------------------------------------------------------*/ 748/*----------------------------------------------------------------------*/
738/* 749/*
739 * window size/position calculcations for XSizeHint and other storage. 750 * window size/position calculcations for XSizeHint and other storage.
740 * if width/height are non-zero then override calculated width/height 751 * if width/height are non-zero then override calculated width/height
741 */ 752 */
874 * Called after a window size change. 885 * Called after a window size change.
875 */ 886 */
876void 887void
877rxvt_term::tt_winch () 888rxvt_term::tt_winch ()
878{ 889{
879 if (pty.pty < 0) 890 if (pty->pty < 0)
880 return; 891 return;
881 892
882 struct winsize ws; 893 struct winsize ws;
883 894
884 ws.ws_col = ncol; 895 ws.ws_col = ncol;
885 ws.ws_row = nrow; 896 ws.ws_row = nrow;
886 ws.ws_xpixel = width; 897 ws.ws_xpixel = width;
887 ws.ws_ypixel = height; 898 ws.ws_ypixel = height;
888 (void)ioctl (pty.pty, TIOCSWINSZ, &ws); 899 (void)ioctl (pty->pty, TIOCSWINSZ, &ws);
889 900
890#if 0 901#if 0
891 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly 902 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
892 if (cmd_pid) /* force through to the command */ 903 if (cmd_pid) /* force through to the command */
893 kill (-cmd_pid, SIGWINCH); 904 kill (-cmd_pid, SIGWINCH);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines