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