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.193 by root, Sat Jan 21 14:25:05 2006 UTC vs.
Revision 1.196 by root, Sun Jan 22 04:01:52 2006 UTC

450 _exit (EXIT_FAILURE); 450 _exit (EXIT_FAILURE);
451} 451}
452 452
453/*----------------------------------------------------------------------*/ 453/*----------------------------------------------------------------------*/
454bool 454bool
455rxvt_term::init (int argc, const char *const *argv) 455rxvt_term::init (int argc, const char *const *argv, stringvec *envv)
456{ 456{
457 this->envv = envv;
458
457 SET_R (this); 459 SET_R (this);
458 set_locale (""); 460 set_locale ("");
459 set_environ (envv); // few things in X do not call setlocale :( 461 set_environ (envv); // few things in X do not call setlocale :(
460 462
461 if (!init_vars ()) 463 if (!init_vars ())
472#ifdef HAVE_SCROLLBARS 474#ifdef HAVE_SCROLLBARS
473 if (OPTION (Opt_scrollBar)) 475 if (OPTION (Opt_scrollBar))
474 scrollBar.setIdle (); /* set existence for size calculations */ 476 scrollBar.setIdle (); /* set existence for size calculations */
475#endif 477#endif
476 478
477 pty = rxvt_new_ptytty (); 479 pty = ptytty::create ();
478 480
479 create_windows (argc, argv); 481 create_windows (argc, argv);
480 482
481 dDisp; 483 dDisp;
482 484
548char **rxvt_environ; // startup environment 550char **rxvt_environ; // startup environment
549 551
550void 552void
551rxvt_init () 553rxvt_init ()
552{ 554{
553 uid_t uid = getuid (); 555 ptytty::init ();
554 gid_t gid = getgid ();
555
556 // before doing anything else, check for setuid/setgid operation,
557 // start the helper process and drop privileges
558 if (uid != geteuid ()
559 || gid != getegid ())
560 {
561#if PTYTTY_HELPER
562 rxvt_ptytty_server ();
563#else
564 rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n");
565#endif
566
567 // drop privileges
568#if HAVE_SETRESUID
569 setresgid (gid, gid, gid);
570 setresuid (uid, uid, uid);
571#elif HAVE_SETREUID
572 setregid (gid, gid);
573 setreuid (uid, uid);
574#elif HAVE_SETUID
575 setgid (gid);
576 setuid (uid);
577#endif
578
579 if (uid != geteuid ()
580 || gid != getegid ())
581 rxvt_fatal ("unable to drop privileges, aborting.\n");
582 }
583 556
584 rxvt_environ = environ; 557 rxvt_environ = environ;
585 558
586 signal (SIGHUP, SIG_IGN); 559 signal (SIGHUP, SIG_IGN);
587 signal (SIGPIPE, SIG_IGN); 560 signal (SIGPIPE, SIG_IGN);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines