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.157 by root, Tue Jan 3 18:11:34 2006 UTC vs.
Revision 1.168 by root, Sun Jan 8 08:49:20 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
206 pty.put (); 221 pty.put ();
207} 222}
208 223
209rxvt_term::~rxvt_term () 224rxvt_term::~rxvt_term ()
210{ 225{
211 PERL_INVOKE ((this, HOOK_DESTROY, DT_END)); 226 HOOK_INVOKE ((this, HOOK_DESTROY, DT_END));
212 227
213 termlist.erase (find (termlist.begin (), termlist.end(), this)); 228 termlist.erase (find (termlist.begin (), termlist.end(), this));
214 229
215 emergency_cleanup (); 230 emergency_cleanup ();
216 231
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] && *rs[Rs_perl_ext]) 513 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
514 || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2])
515 || (rs[Rs_perl_eval] && *rs[Rs_perl_eval]))
493 { 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
494 rxvt_perl.init (); 530 rxvt_perl.init ();
495 PERL_INVOKE ((this, HOOK_INIT, DT_END)); 531 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
496 } 532 }
497#endif 533#endif
498 534
499 create_windows (argc, argv); 535 create_windows (argc, argv);
500 536
532 568
533 init_command (cmd_argv); 569 init_command (cmd_argv);
534 570
535 free (cmd_argv); 571 free (cmd_argv);
536 572
573 if (pty.pty >= 0)
537 pty_ev.start (pty.pty, EVENT_READ); 574 pty_ev.start (pty.pty, EVENT_READ);
538 575
539 check_ev.start (); 576 check_ev.start ();
540 577
541 PERL_INVOKE ((this, HOOK_START, DT_END)); 578 HOOK_INVOKE ((this, HOOK_START, DT_END));
542 579
543 return true; 580 return true;
544} 581}
545 582
546static struct sig_handlers 583static struct sig_handlers
607 /* signal (SIGURG, SIG_DFL); */ 644 /* signal (SIGURG, SIG_DFL); */
608 645
609 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 646 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
610 // TODO: handle this with exceptions and tolerate the memory loss 647 // TODO: handle this with exceptions and tolerate the memory loss
611 XSetIOErrorHandler (rxvt_xioerror_handler); 648 XSetIOErrorHandler (rxvt_xioerror_handler);
649
650#ifdef USE_XGETDEFAULT
651 XrmInitialize ();
652#endif
612} 653}
613 654
614/* ------------------------------------------------------------------------- * 655/* ------------------------------------------------------------------------- *
615 * MEMORY ALLOCATION WRAPPERS * 656 * MEMORY ALLOCATION WRAPPERS *
616 * ------------------------------------------------------------------------- */ 657 * ------------------------------------------------------------------------- */
652 * ------------------------------------------------------------------------- */ 693 * ------------------------------------------------------------------------- */
653/* take care of suid/sgid super-user (root) privileges */ 694/* take care of suid/sgid super-user (root) privileges */
654void 695void
655rxvt_privileges (rxvt_privaction action) 696rxvt_privileges (rxvt_privaction action)
656{ 697{
657#if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__)
658 static uid_t euid;
659 static gid_t egid;
660#endif
661
662#if ! defined(__CYGWIN32__) 698#if ! defined(__CYGWIN32__)
663# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) 699# if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
664 /* setreuid () is the poor man's setuid (), seteuid () */ 700 /* setreuid () is the poor man's setuid (), seteuid () */
665# define seteuid(a) setreuid(-1, (a)) 701# define seteuid(a) setreuid(-1, (a))
666# define setegid(a) setregid(-1, (a)) 702# define setegid(a) setregid(-1, (a))
676 */ 712 */
677 seteuid (getuid ()); 713 seteuid (getuid ());
678 setegid (getgid ()); 714 setegid (getgid ());
679 break; 715 break;
680 case SAVE: 716 case SAVE:
681 euid = geteuid (); 717 saved_euid = geteuid ();
682 egid = getegid (); 718 saved_egid = getegid ();
683 break; 719 break;
684 case RESTORE: 720 case RESTORE:
685 seteuid (euid); 721 seteuid (saved_euid);
686 setegid (egid); 722 setegid (saved_egid);
687 break; 723 break;
688 } 724 }
689# else 725# else
690 switch (action) 726 switch (action)
691 { 727 {
923 prop.height += lineSpace; 959 prop.height += lineSpace;
924 fs->set_prop (prop); 960 fs->set_prop (prop);
925 961
926 fwidth = prop.width; 962 fwidth = prop.width;
927 fheight = prop.height; 963 fheight = prop.height;
928 fbase = (*fs)[1]->ascent; 964 fbase = prop.ascent;
929 965
930 for (int style = 1; style < 4; style++) 966 for (int style = 1; style < 4; style++)
931 { 967 {
932#if ENABLE_STYLES 968#if ENABLE_STYLES
933 const char *res = rs[Rs_font + style]; 969 const char *res = rs[Rs_font + style];
1024 i = atoi (color); 1060 i = atoi (color);
1025 1061
1026 if (i >= 8 && i <= 15) 1062 if (i >= 8 && i <= 15)
1027 { /* bright colors */ 1063 { /* bright colors */
1028 i -= 8; 1064 i -= 8;
1029# ifndef NO_BRIGHTCOLOR
1030 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 1065 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
1031 SET_PIXCOLOR (idx); 1066 SET_PIXCOLOR (idx);
1032 goto done; 1067 goto done;
1033# endif
1034 } 1068 }
1035 1069
1036 if (i >= 0 && i <= 7) 1070 if (i >= 0 && i <= 7)
1037 { /* normal colors */ 1071 { /* normal colors */
1038 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1072 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
1222 } 1256 }
1223 1257
1224 if (menubar_visible ()) 1258 if (menubar_visible ())
1225 XMoveResizeWindow (disp, menuBar.win, 1259 XMoveResizeWindow (disp, menuBar.win,
1226 window_vt_x, 0, 1260 window_vt_x, 0,
1227 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1261 width, menuBar_TotalHeight ());
1228 1262
1229 XMoveResizeWindow (disp, vt, 1263 XMoveResizeWindow (disp, vt,
1230 window_vt_x, window_vt_y, 1264 window_vt_x, window_vt_y,
1231 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1265 width, height);
1232 1266
1233 scr_clear (); 1267 scr_clear ();
1234#ifdef XPM_BACKGROUND 1268#ifdef XPM_BACKGROUND
1235 resize_pixmap (); 1269 resize_pixmap ();
1236#endif 1270#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines