… | |
… | |
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 = ptytty_new (); |
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 | 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); |
… | |
… | |
1060 | * -------------------------------------------------------------------- */ |
1031 | * -------------------------------------------------------------------- */ |
1061 | void |
1032 | void |
1062 | rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent) |
1033 | rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent) |
1063 | { |
1034 | { |
1064 | int fix_screen; |
1035 | int fix_screen; |
1065 | int old_width = szHint.width, old_height = szHint.height; |
1036 | int old_width = szHint.width; |
|
|
1037 | int old_height = szHint.height; |
1066 | dDisp; |
1038 | dDisp; |
1067 | |
1039 | |
1068 | window_calc (newwidth, newheight); |
1040 | window_calc (newwidth, newheight); |
1069 | XSetWMNormalHints (disp, parent[0], &szHint); |
1041 | XSetWMNormalHints (disp, parent[0], &szHint); |
1070 | |
1042 | |
… | |
… | |
1092 | { |
1064 | { |
1093 | x -= x1; |
1065 | x -= x1; |
1094 | y -= y1; |
1066 | y -= y1; |
1095 | } |
1067 | } |
1096 | |
1068 | |
1097 | x1 = (DisplayWidth (disp, display->screen) - old_width) / 2; |
1069 | x1 = (DisplayWidth (disp, display->screen) - old_width ) / 2; |
1098 | y1 = (DisplayHeight (disp, display->screen) - old_height) / 2; |
1070 | y1 = (DisplayHeight (disp, display->screen) - old_height) / 2; |
1099 | dx = old_width - szHint.width; |
1071 | dx = old_width - szHint.width; |
1100 | dy = old_height - szHint.height; |
1072 | dy = old_height - szHint.height; |
1101 | |
1073 | |
1102 | /* Check position of the center of the window */ |
1074 | /* Check position of the center of the window */ |
1103 | if (x < x1) /* left half */ |
1075 | if (x < x1) /* left half */ |
1104 | dx = 0; |
1076 | dx = 0; |
… | |
… | |
1137 | resize_pixmap (); |
1109 | resize_pixmap (); |
1138 | #endif |
1110 | #endif |
1139 | } |
1111 | } |
1140 | |
1112 | |
1141 | if (fix_screen || old_height == 0) |
1113 | if (fix_screen || old_height == 0) |
1142 | { |
|
|
1143 | int curr_screen = -1; |
|
|
1144 | int old_ncol = prev_ncol; |
|
|
1145 | |
|
|
1146 | /* scr_reset only works on the primary screen */ |
|
|
1147 | if (old_height) /* this is not the first time through */ |
|
|
1148 | { |
|
|
1149 | unsigned int ocol = ncol; |
|
|
1150 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
|
|
1151 | curr_screen = scr_change_screen (PRIMARY); |
|
|
1152 | ncol = ocol; |
|
|
1153 | } |
|
|
1154 | |
|
|
1155 | scr_reset (); |
1114 | scr_reset (); |
1156 | |
|
|
1157 | if (curr_screen >= 0) /* this is not the first time through */ |
|
|
1158 | { |
|
|
1159 | scr_change_screen (curr_screen); |
|
|
1160 | selection_check (old_ncol != ncol ? 4 : 0); |
|
|
1161 | } |
|
|
1162 | } |
|
|
1163 | |
|
|
1164 | old_width = szHint.width; |
|
|
1165 | old_height = szHint.height; |
|
|
1166 | |
1115 | |
1167 | #ifdef XPM_BACKGROUND |
1116 | #ifdef XPM_BACKGROUND |
1168 | if (pixmap) |
1117 | if (pixmap) |
1169 | scr_touch (false); |
1118 | scr_touch (false); |
1170 | #endif |
1119 | #endif |