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.163 by root, Fri Jan 6 02:11:15 2006 UTC vs.
Revision 1.169 by root, Tue Jan 10 18:09:22 2006 UTC

11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> 11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA>
12 * - extensive modifications 12 * - extensive modifications
13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
15 * - extensive modifications 15 * - extensive modifications
16 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 16 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or 20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version. 21 * (at your option) any later version.
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}
273 // TODO: free pixcolours, colours should become part of rxvt_display 288 // TODO: free pixcolours, colours should become part of rxvt_display
274 289
275 delete pix_colors_focused; 290 delete pix_colors_focused;
276#if OFF_FOCUS_FADING 291#if OFF_FOCUS_FADING
277 delete pix_colors_unfocused; 292 delete pix_colors_unfocused;
293#endif
294#if USE_XGETDEFAULT
295 XrmDestroyDatabase (xrmdatabase);
278#endif 296#endif
279 297
280 displays.put (display); 298 displays.put (display);
281 299
282 scr_release (); 300 scr_release ();
487 if (OPTION (Opt_scrollBar)) 505 if (OPTION (Opt_scrollBar))
488 scrollBar.setIdle (); /* set existence for size calculations */ 506 scrollBar.setIdle (); /* set existence for size calculations */
489#endif 507#endif
490 508
491#if ENABLE_PERL 509#if ENABLE_PERL
510 if (!rs[Rs_perl_ext_1])
511 rs[Rs_perl_ext_1] = "default";
512
492 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 513 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
493 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) 514 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
494 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) 515 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
495 { 516 {
517#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
518 // ignore some perl-related arguments if some bozo installed us set[ug]id
519 if (rxvt_tainted ())
520 {
521 if ((rs[Rs_perl_lib] && *rs[Rs_perl_lib])
522 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
523 {
524 rxvt_warn ("running with elevated privileges: ignoring perl-lib and perl-eval.\n");
525 rs[Rs_perl_lib] = 0;
526 rs[Rs_perl_eval] = 0;
527 }
528 }
529#endif
496 rxvt_perl.init (); 530 rxvt_perl.init ();
497 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 531 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
498 } 532 }
499#endif 533#endif
500 534
610 /* signal (SIGURG, SIG_DFL); */ 644 /* signal (SIGURG, SIG_DFL); */
611 645
612 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 646 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
613 // TODO: handle this with exceptions and tolerate the memory loss 647 // TODO: handle this with exceptions and tolerate the memory loss
614 XSetIOErrorHandler (rxvt_xioerror_handler); 648 XSetIOErrorHandler (rxvt_xioerror_handler);
649
650#ifdef USE_XGETDEFAULT
651 XrmInitialize ();
652#endif
615} 653}
616 654
617/* ------------------------------------------------------------------------- * 655/* ------------------------------------------------------------------------- *
618 * MEMORY ALLOCATION WRAPPERS * 656 * MEMORY ALLOCATION WRAPPERS *
619 * ------------------------------------------------------------------------- */ 657 * ------------------------------------------------------------------------- */
655 * ------------------------------------------------------------------------- */ 693 * ------------------------------------------------------------------------- */
656/* take care of suid/sgid super-user (root) privileges */ 694/* take care of suid/sgid super-user (root) privileges */
657void 695void
658rxvt_privileges (rxvt_privaction action) 696rxvt_privileges (rxvt_privaction action)
659{ 697{
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__) 698#if ! defined(__CYGWIN32__)
666# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 699# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
667 /* setreuid () is the poor man's setuid (), seteuid () */ 700 /* setreuid () is the poor man's setuid (), seteuid () */
668# define seteuid(a) setreuid(-1, (a)) 701# define seteuid(a) setreuid(-1, (a))
669# define setegid(a) setregid(-1, (a)) 702# define setegid(a) setregid(-1, (a))
679 */ 712 */
680 seteuid (getuid ()); 713 seteuid (getuid ());
681 setegid (getgid ()); 714 setegid (getgid ());
682 break; 715 break;
683 case SAVE: 716 case SAVE:
684 euid = geteuid (); 717 saved_euid = geteuid ();
685 egid = getegid (); 718 saved_egid = getegid ();
686 break; 719 break;
687 case RESTORE: 720 case RESTORE:
688 seteuid (euid); 721 seteuid (saved_euid);
689 setegid (egid); 722 setegid (saved_egid);
690 break; 723 break;
691 } 724 }
692# else 725# else
693 switch (action) 726 switch (action)
694 { 727 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines