… | |
… | |
474 | #ifdef HAVE_SCROLLBARS |
474 | #ifdef HAVE_SCROLLBARS |
475 | if (OPTION (Opt_scrollBar)) |
475 | if (OPTION (Opt_scrollBar)) |
476 | scrollBar.setIdle (); /* set existence for size calculations */ |
476 | scrollBar.setIdle (); /* set existence for size calculations */ |
477 | #endif |
477 | #endif |
478 | |
478 | |
479 | pty = rxvt_new_ptytty (); |
479 | pty = ptytty::create (); |
480 | |
480 | |
481 | create_windows (argc, argv); |
481 | create_windows (argc, argv); |
482 | |
482 | |
483 | dDisp; |
483 | dDisp; |
484 | |
484 | |
… | |
… | |
550 | char **rxvt_environ; // startup environment |
550 | char **rxvt_environ; // startup environment |
551 | |
551 | |
552 | void |
552 | void |
553 | rxvt_init () |
553 | rxvt_init () |
554 | { |
554 | { |
555 | uid_t uid = getuid (); |
555 | ptytty::init (); |
556 | gid_t gid = getgid (); |
|
|
557 | |
|
|
558 | // before doing anything else, check for setuid/setgid operation, |
|
|
559 | // start the helper process and drop privileges |
|
|
560 | if (uid != geteuid () |
|
|
561 | || gid != getegid ()) |
|
|
562 | { |
|
|
563 | #if PTYTTY_HELPER |
|
|
564 | rxvt_ptytty_server (); |
|
|
565 | #else |
|
|
566 | rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n"); |
|
|
567 | #endif |
|
|
568 | |
|
|
569 | // drop privileges |
|
|
570 | #if HAVE_SETRESUID |
|
|
571 | setresgid (gid, gid, gid); |
|
|
572 | setresuid (uid, uid, uid); |
|
|
573 | #elif HAVE_SETREUID |
|
|
574 | setregid (gid, gid); |
|
|
575 | setreuid (uid, uid); |
|
|
576 | #elif HAVE_SETUID |
|
|
577 | setgid (gid); |
|
|
578 | setuid (uid); |
|
|
579 | #endif |
|
|
580 | |
|
|
581 | if (uid != geteuid () |
|
|
582 | || gid != getegid ()) |
|
|
583 | rxvt_fatal ("unable to drop privileges, aborting.\n"); |
|
|
584 | } |
|
|
585 | |
556 | |
586 | rxvt_environ = environ; |
557 | rxvt_environ = environ; |
587 | |
558 | |
588 | signal (SIGHUP, SIG_IGN); |
559 | signal (SIGHUP, SIG_IGN); |
589 | signal (SIGPIPE, SIG_IGN); |
560 | signal (SIGPIPE, SIG_IGN); |