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.164 by root, Fri Jan 6 05:37:59 2006 UTC vs.
Revision 1.172 by root, Wed Jan 11 05:14:26 2006 UTC

46 46
47#ifdef HAVE_TERMIOS_H 47#ifdef HAVE_TERMIOS_H
48# include <termios.h> 48# include <termios.h>
49#endif 49#endif
50 50
51#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
52static uid_t saved_euid;
53static gid_t saved_egid;
54#endif
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
51vector<rxvt_term *> rxvt_term::termlist; 66vector<rxvt_term *> rxvt_term::termlist;
52 67
53static char curlocale[128], savelocale[128]; 68static char curlocale[128], savelocale[128];
54 69
55bool 70bool
61 strncpy (curlocale, locale, 128); 76 strncpy (curlocale, locale, 128);
62 setlocale (LC_CTYPE, curlocale); 77 setlocale (LC_CTYPE, curlocale);
63 return true; 78 return true;
64} 79}
65 80
66bool 81void
67rxvt_push_locale (const char *locale) 82rxvt_push_locale (const char *locale)
68{ 83{
69 strcpy (savelocale, curlocale); 84 strcpy (savelocale, curlocale);
70 rxvt_set_locale (locale); 85 rxvt_set_locale (locale);
71} 86}
269 if (parent[0]) 284 if (parent[0])
270 XDestroyWindow (disp, parent[0]); 285 XDestroyWindow (disp, parent[0]);
271 } 286 }
272 287
273 // TODO: free pixcolours, colours should become part of rxvt_display 288 // TODO: free pixcolours, colours should become part of rxvt_display
274
275 delete pix_colors_focused; 289 delete pix_colors_focused;
276#if OFF_FOCUS_FADING 290#if OFF_FOCUS_FADING
277 delete pix_colors_unfocused; 291 delete pix_colors_unfocused;
278#endif 292#endif
279 293
464/*----------------------------------------------------------------------*/ 478/*----------------------------------------------------------------------*/
465bool 479bool
466rxvt_term::init (int argc, const char *const *argv) 480rxvt_term::init (int argc, const char *const *argv)
467{ 481{
468 SET_R (this); 482 SET_R (this);
483 TEMP_ENV; // few things in X do not call setlocale :(
469 484
470 set_locale (""); 485 set_locale ("");
471 486
472 if (!init_vars ()) 487 if (!init_vars ())
473 return false; 488 return false;
487 if (OPTION (Opt_scrollBar)) 502 if (OPTION (Opt_scrollBar))
488 scrollBar.setIdle (); /* set existence for size calculations */ 503 scrollBar.setIdle (); /* set existence for size calculations */
489#endif 504#endif
490 505
491#if ENABLE_PERL 506#if ENABLE_PERL
507 if (!rs[Rs_perl_ext_1])
508 rs[Rs_perl_ext_1] = "default";
509
492 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 510 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
493 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) 511 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
494 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) 512 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
495 { 513 {
514#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
515 // ignore some perl-related arguments if some bozo installed us set[ug]id
516 if (rxvt_tainted ())
517 {
518 if ((rs[Rs_perl_lib] && *rs[Rs_perl_lib])
519 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
520 {
521 rxvt_warn ("running with elevated privileges: ignoring perl-lib and perl-eval.\n");
522 rs[Rs_perl_lib] = 0;
523 rs[Rs_perl_eval] = 0;
524 }
525 }
526#endif
496 rxvt_perl.init (); 527 rxvt_perl.init ();
497 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 528 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
498 } 529 }
499#endif 530#endif
500 531
502 533
503 dDisp; 534 dDisp;
504 535
505 init_xlocale (); 536 init_xlocale ();
506 537
507 scr_reset (); /* initialize screen */ 538 scr_reset (); // initialize screen
508 539
509#if 0 540#if 0
510 XSynchronize (disp, True); 541 XSynchronize (disp, True);
511#endif 542#endif
512 543
610 /* signal (SIGURG, SIG_DFL); */ 641 /* signal (SIGURG, SIG_DFL); */
611 642
612 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 643 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
613 // TODO: handle this with exceptions and tolerate the memory loss 644 // TODO: handle this with exceptions and tolerate the memory loss
614 XSetIOErrorHandler (rxvt_xioerror_handler); 645 XSetIOErrorHandler (rxvt_xioerror_handler);
646
647 XrmInitialize ();
615} 648}
616 649
617/* ------------------------------------------------------------------------- * 650/* ------------------------------------------------------------------------- *
618 * MEMORY ALLOCATION WRAPPERS * 651 * MEMORY ALLOCATION WRAPPERS *
619 * ------------------------------------------------------------------------- */ 652 * ------------------------------------------------------------------------- */
655 * ------------------------------------------------------------------------- */ 688 * ------------------------------------------------------------------------- */
656/* take care of suid/sgid super-user (root) privileges */ 689/* take care of suid/sgid super-user (root) privileges */
657void 690void
658rxvt_privileges (rxvt_privaction action) 691rxvt_privileges (rxvt_privaction action)
659{ 692{
660#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
661 static uid_t euid;
662 static gid_t egid;
663#endif
664
665#if ! defined(__CYGWIN32__) 693#if ! defined(__CYGWIN32__)
666# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 694# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
667 /* setreuid () is the poor man's setuid (), seteuid () */ 695 /* setreuid () is the poor man's setuid (), seteuid () */
668# define seteuid(a) setreuid(-1, (a)) 696# define seteuid(a) setreuid(-1, (a))
669# define setegid(a) setregid(-1, (a)) 697# define setegid(a) setregid(-1, (a))
679 */ 707 */
680 seteuid (getuid ()); 708 seteuid (getuid ());
681 setegid (getgid ()); 709 setegid (getgid ());
682 break; 710 break;
683 case SAVE: 711 case SAVE:
684 euid = geteuid (); 712 saved_euid = geteuid ();
685 egid = getegid (); 713 saved_egid = getegid ();
686 break; 714 break;
687 case RESTORE: 715 case RESTORE:
688 seteuid (euid); 716 seteuid (saved_euid);
689 setegid (egid); 717 setegid (saved_egid);
690 break; 718 break;
691 } 719 }
692# else 720# else
693 switch (action) 721 switch (action)
694 { 722 {
1418 unsigned long fg, bg; 1446 unsigned long fg, bg;
1419 const char *p; 1447 const char *p;
1420 char **s; 1448 char **s;
1421 XIMStyles *xim_styles; 1449 XIMStyles *xim_styles;
1422 1450
1451 TEMP_ENV;
1452
1423 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1453 if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
1424 return false; 1454 return false;
1425 1455
1426 D_MAIN ((stderr, "rxvt_IM_get_IC ()")); 1456 D_MAIN ((stderr, "rxvt_IM_get_IC ()"));
1427 input_method = display->get_xim (locale, modifiers); 1457 input_method = display->get_xim (locale, modifiers);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines