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.167 by root, Sun Jan 8 08:43:11 2006 UTC vs.
Revision 1.171 by root, Wed Jan 11 03:13:26 2006 UTC

51#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) 51#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
52static uid_t saved_euid; 52static uid_t saved_euid;
53static gid_t saved_egid; 53static gid_t saved_egid;
54#endif 54#endif
55 55
56bool
57rxvt_tainted ()
58{
59#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
60 return getuid () != saved_euid || getgid () != saved_egid;
61#else
62 return false;
63#endif
64}
65
56vector<rxvt_term *> rxvt_term::termlist; 66vector<rxvt_term *> rxvt_term::termlist;
57 67
58static char curlocale[128], savelocale[128]; 68static char curlocale[128], savelocale[128];
59 69
60bool 70bool
66 strncpy (curlocale, locale, 128); 76 strncpy (curlocale, locale, 128);
67 setlocale (LC_CTYPE, curlocale); 77 setlocale (LC_CTYPE, curlocale);
68 return true; 78 return true;
69} 79}
70 80
71bool 81void
72rxvt_push_locale (const char *locale) 82rxvt_push_locale (const char *locale)
73{ 83{
74 strcpy (savelocale, curlocale); 84 strcpy (savelocale, curlocale);
75 rxvt_set_locale (locale); 85 rxvt_set_locale (locale);
76} 86}
278 // TODO: free pixcolours, colours should become part of rxvt_display 288 // TODO: free pixcolours, colours should become part of rxvt_display
279 289
280 delete pix_colors_focused; 290 delete pix_colors_focused;
281#if OFF_FOCUS_FADING 291#if OFF_FOCUS_FADING
282 delete pix_colors_unfocused; 292 delete pix_colors_unfocused;
283#endif
284#if USE_XGETDEFAULT
285 XrmDestroyDatabase (xrmdatabase);
286#endif 293#endif
287 294
288 displays.put (display); 295 displays.put (display);
289 296
290 scr_release (); 297 scr_release ();
472/*----------------------------------------------------------------------*/ 479/*----------------------------------------------------------------------*/
473bool 480bool
474rxvt_term::init (int argc, const char *const *argv) 481rxvt_term::init (int argc, const char *const *argv)
475{ 482{
476 SET_R (this); 483 SET_R (this);
484 TEMP_ENV; // few things in X do not call setlocale :(
477 485
478 set_locale (""); 486 set_locale ("");
479 487
480 if (!init_vars ()) 488 if (!init_vars ())
481 return false; 489 return false;
502 510
503 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 511 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
504 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) 512 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
505 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) 513 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
506 { 514 {
507 bool tainted = false;
508
509#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) 515#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
510 // ignore some perl-related arguments if some bozo installed us set[ug]id 516 // ignore some perl-related arguments if some bozo installed us set[ug]id
511 if (getuid () != saved_euid || getgid () != saved_egid) 517 if (rxvt_tainted ())
512 { 518 {
513 tainted = true;
514
515 if ((rs[Rs_perl_lib] && *rs[Rs_perl_lib]) 519 if ((rs[Rs_perl_lib] && *rs[Rs_perl_lib])
516 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) 520 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
517 { 521 {
518 rxvt_warn ("running with elevated privileges: ignoring perl-lib and perl-eval.\n"); 522 rxvt_warn ("running with elevated privileges: ignoring perl-lib and perl-eval.\n");
519 rs[Rs_perl_lib] = 0; 523 rs[Rs_perl_lib] = 0;
520 rs[Rs_perl_eval] = "our $tainted = 1"; 524 rs[Rs_perl_eval] = 0;
521 } 525 }
522 } 526 }
523#endif 527#endif
524 rxvt_perl.init (tainted); 528 rxvt_perl.init ();
525 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 529 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
526 } 530 }
527#endif 531#endif
528 532
529 create_windows (argc, argv); 533 create_windows (argc, argv);
530 534
531 dDisp; 535 dDisp;
532 536
533 init_xlocale (); 537 init_xlocale ();
534 538
535 scr_reset (); /* initialize screen */ 539 scr_reset (); // initialize screen
536 540
537#if 0 541#if 0
538 XSynchronize (disp, True); 542 XSynchronize (disp, True);
539#endif 543#endif
540 544
639 643
640 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 644 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
641 // TODO: handle this with exceptions and tolerate the memory loss 645 // TODO: handle this with exceptions and tolerate the memory loss
642 XSetIOErrorHandler (rxvt_xioerror_handler); 646 XSetIOErrorHandler (rxvt_xioerror_handler);
643 647
644#ifdef USE_XGETDEFAULT
645 XrmInitialize (); 648 XrmInitialize ();
646#endif
647} 649}
648 650
649/* ------------------------------------------------------------------------- * 651/* ------------------------------------------------------------------------- *
650 * MEMORY ALLOCATION WRAPPERS * 652 * MEMORY ALLOCATION WRAPPERS *
651 * ------------------------------------------------------------------------- */ 653 * ------------------------------------------------------------------------- */
1445 unsigned long fg, bg; 1447 unsigned long fg, bg;
1446 const char *p; 1448 const char *p;
1447 char **s; 1449 char **s;
1448 XIMStyles *xim_styles; 1450 XIMStyles *xim_styles;
1449 1451
1452 TEMP_ENV;
1453
1450 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1454 if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
1451 return false; 1455 return false;
1452 1456
1453 D_MAIN ((stderr, "rxvt_IM_get_IC ()")); 1457 D_MAIN ((stderr, "rxvt_IM_get_IC ()"));
1454 input_method = display->get_xim (locale, modifiers); 1458 input_method = display->get_xim (locale, modifiers);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines