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.166 by root, Sun Jan 8 07:55:36 2006 UTC vs.
Revision 1.173 by root, Wed Jan 11 19:55:34 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
279#if USE_XGETDEFAULT
280 XrmDestroyDatabase (xrmdatabase);
281#endif 292#endif
282 293
283 displays.put (display); 294 displays.put (display);
284 295
285 scr_release (); 296 scr_release ();
467/*----------------------------------------------------------------------*/ 478/*----------------------------------------------------------------------*/
468bool 479bool
469rxvt_term::init (int argc, const char *const *argv) 480rxvt_term::init (int argc, const char *const *argv)
470{ 481{
471 SET_R (this); 482 SET_R (this);
483 TEMP_ENV; // few things in X do not call setlocale :(
472 484
473 set_locale (""); 485 set_locale ("");
474 486
475 if (!init_vars ()) 487 if (!init_vars ())
476 return false; 488 return false;
497 509
498 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 510 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
499 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) 511 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
500 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) 512 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
501 { 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
502 rxvt_perl.init (); 527 rxvt_perl.init ();
503 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 528 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
504 } 529 }
505#endif 530#endif
506 531
508 533
509 dDisp; 534 dDisp;
510 535
511 init_xlocale (); 536 init_xlocale ();
512 537
513 scr_reset (); /* initialize screen */ 538 scr_reset (); // initialize screen
514 539
515#if 0 540#if 0
516 XSynchronize (disp, True); 541 XSynchronize (disp, True);
517#endif 542#endif
518 543
617 642
618 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 643 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
619 // TODO: handle this with exceptions and tolerate the memory loss 644 // TODO: handle this with exceptions and tolerate the memory loss
620 XSetIOErrorHandler (rxvt_xioerror_handler); 645 XSetIOErrorHandler (rxvt_xioerror_handler);
621 646
622#ifdef USE_XGETDEFAULT
623 XrmInitialize (); 647 XrmInitialize ();
624#endif
625} 648}
626 649
627/* ------------------------------------------------------------------------- * 650/* ------------------------------------------------------------------------- *
628 * MEMORY ALLOCATION WRAPPERS * 651 * MEMORY ALLOCATION WRAPPERS *
629 * ------------------------------------------------------------------------- */ 652 * ------------------------------------------------------------------------- */
665 * ------------------------------------------------------------------------- */ 688 * ------------------------------------------------------------------------- */
666/* take care of suid/sgid super-user (root) privileges */ 689/* take care of suid/sgid super-user (root) privileges */
667void 690void
668rxvt_privileges (rxvt_privaction action) 691rxvt_privileges (rxvt_privaction action)
669{ 692{
670#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
671 static uid_t euid;
672 static gid_t egid;
673#endif
674
675#if ! defined(__CYGWIN32__) 693#if ! defined(__CYGWIN32__)
676# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 694# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
677 /* setreuid () is the poor man's setuid (), seteuid () */ 695 /* setreuid () is the poor man's setuid (), seteuid () */
678# define seteuid(a) setreuid(-1, (a)) 696# define seteuid(a) setreuid(-1, (a))
679# define setegid(a) setregid(-1, (a)) 697# define setegid(a) setregid(-1, (a))
685 case IGNORE: 703 case IGNORE:
686 /* 704 /*
687 * change effective uid/gid - not real uid/gid - so we can switch 705 * change effective uid/gid - not real uid/gid - so we can switch
688 * back to root later, as required 706 * back to root later, as required
689 */ 707 */
708 setegid (getgid ());
690 seteuid (getuid ()); 709 seteuid (getuid ());
691 setegid (getgid ());
692 break; 710 break;
693 case SAVE: 711 case SAVE:
694 euid = geteuid ();
695 egid = getegid (); 712 saved_egid = getegid ();
713 saved_euid = geteuid ();
696 break; 714 break;
697 case RESTORE: 715 case RESTORE:
698 seteuid (euid);
699 setegid (egid); 716 setegid (saved_egid);
717 seteuid (saved_euid);
700 break; 718 break;
701 } 719 }
702# else 720# else
703 switch (action) 721 switch (action)
704 { 722 {
705 case IGNORE: 723 case IGNORE:
724 setgid (getgid ());
706 setuid (getuid ()); 725 setuid (getuid ());
707 setgid (getgid ());
708 /* FALLTHROUGH */ 726 /* FALLTHROUGH */
709 case SAVE: 727 case SAVE:
710 /* FALLTHROUGH */ 728 /* FALLTHROUGH */
711 case RESTORE: 729 case RESTORE:
712 break; 730 break;
1428 unsigned long fg, bg; 1446 unsigned long fg, bg;
1429 const char *p; 1447 const char *p;
1430 char **s; 1448 char **s;
1431 XIMStyles *xim_styles; 1449 XIMStyles *xim_styles;
1432 1450
1451 TEMP_ENV;
1452
1433 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1453 if (! ((p = XSetLocaleModifiers (modifiers)) && *p))
1434 return false; 1454 return false;
1435 1455
1436 D_MAIN ((stderr, "rxvt_IM_get_IC ()")); 1456 D_MAIN ((stderr, "rxvt_IM_get_IC ()"));
1437 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