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.191 by root, Fri Jan 20 10:27:08 2006 UTC vs.
Revision 1.196 by root, Sun Jan 22 04:01:52 2006 UTC

170 pointer_ev (this, &rxvt_term::pointer_cb), 170 pointer_ev (this, &rxvt_term::pointer_cb),
171#endif 171#endif
172#ifdef USE_XIM 172#ifdef USE_XIM
173 im_ev (this, &rxvt_term::im_cb), 173 im_ev (this, &rxvt_term::im_cb),
174#endif 174#endif
175#ifndef NO_BELL
176 bell_ev (this, &rxvt_term::bell_cb),
177#endif
175 termwin_ev (this, &rxvt_term::x_cb), 178 termwin_ev (this, &rxvt_term::x_cb),
176 vt_ev (this, &rxvt_term::x_cb), 179 vt_ev (this, &rxvt_term::x_cb),
177 child_ev (this, &rxvt_term::child_cb), 180 child_ev (this, &rxvt_term::child_cb),
178 check_ev (this, &rxvt_term::check_cb), 181 check_ev (this, &rxvt_term::check_cb),
179 flush_ev (this, &rxvt_term::flush_cb), 182 flush_ev (this, &rxvt_term::flush_cb),
447 _exit (EXIT_FAILURE); 450 _exit (EXIT_FAILURE);
448} 451}
449 452
450/*----------------------------------------------------------------------*/ 453/*----------------------------------------------------------------------*/
451bool 454bool
452rxvt_term::init (int argc, const char *const *argv) 455rxvt_term::init (int argc, const char *const *argv, stringvec *envv)
453{ 456{
457 this->envv = envv;
458
454 SET_R (this); 459 SET_R (this);
455 set_locale (""); 460 set_locale ("");
456 set_environ (envv); // few things in X do not call setlocale :( 461 set_environ (envv); // few things in X do not call setlocale :(
457 462
458 if (!init_vars ()) 463 if (!init_vars ())
464 469
465#ifdef KEYSYM_RESOURCE 470#ifdef KEYSYM_RESOURCE
466 keyboard->register_done (); 471 keyboard->register_done ();
467#endif 472#endif
468 473
469#if ENABLE_PERL
470 if (!rs[Rs_perl_ext_1])
471 rs[Rs_perl_ext_1] = "default";
472
473 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
474 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
475 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
476 {
477 rxvt_perl.init (this);
478 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
479 }
480#endif
481
482#ifdef HAVE_SCROLLBARS 474#ifdef HAVE_SCROLLBARS
483 if (OPTION (Opt_scrollBar)) 475 if (OPTION (Opt_scrollBar))
484 scrollBar.setIdle (); /* set existence for size calculations */ 476 scrollBar.setIdle (); /* set existence for size calculations */
485#endif 477#endif
486 478
487 pty = rxvt_new_ptytty (); 479 pty = ptytty::create ();
488 480
489 create_windows (argc, argv); 481 create_windows (argc, argv);
490 482
491 dDisp; 483 dDisp;
492 484
558char **rxvt_environ; // startup environment 550char **rxvt_environ; // startup environment
559 551
560void 552void
561rxvt_init () 553rxvt_init ()
562{ 554{
563 uid_t uid = getuid (); 555 ptytty::init ();
564 gid_t gid = getgid ();
565
566 // before doing anything else, check for setuid/setgid operation,
567 // start the helper process and drop privileges
568 if (uid != geteuid ()
569 || gid != getegid ())
570 {
571#if PTYTTY_HELPER
572 rxvt_ptytty_server ();
573#else
574 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
575#endif
576
577 // drop privileges
578#if HAVE_SETRESUID
579 setresgid (gid, gid, gid);
580 setresuid (uid, uid, uid);
581#elif HAVE_SETREUID
582 setregid (gid, gid);
583 setreuid (uid, uid);
584#elif HAVE_SETUID
585 setgid (gid);
586 setuid (uid);
587#endif
588
589 if (uid != geteuid ()
590 || gid != getegid ())
591 rxvt_fatal ("unable to drop privileges, aborting.\n");
592 }
593 556
594 rxvt_environ = environ; 557 rxvt_environ = environ;
595 558
596 signal (SIGHUP, SIG_IGN); 559 signal (SIGHUP, SIG_IGN);
597 signal (SIGPIPE, SIG_IGN); 560 signal (SIGPIPE, SIG_IGN);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines