Changeset 199
- Timestamp:
- 06/21/07 19:54:51 (2 years ago)
- Files:
-
- trunk/configure.ac (modified) (1 diff)
- trunk/src/Makefile.std (modified) (1 diff)
- trunk/src/birth.c (modified) (4 diffs)
- trunk/src/cmd0.c (modified) (1 diff)
- trunk/src/cmd5.c (modified) (3 diffs)
- trunk/src/config.h (modified) (9 diffs)
- trunk/src/defines.h (modified) (1 diff)
- trunk/src/files.c (modified) (1 diff)
- trunk/src/main.c (modified) (2 diffs)
- trunk/src/object1.c (modified) (3 diffs)
- trunk/src/signals.c (modified) (1 diff)
- trunk/src/util.c (modified) (5 diffs)
- trunk/src/xtra2.c (modified) (5 diffs)
- trunk/src/z-file.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/configure.ac
r198 r199 190 190 AC_C_CONST 191 191 AC_TYPE_SIGNAL 192 AC_CHECK_FUNCS([mkstemp set egid can_change_color])192 AC_CHECK_FUNCS([mkstemp setresgid setegid can_change_color]) 193 193 194 194 trunk/src/Makefile.std
r197 r199 38 38 39 39 # Support the GTK2 graphical tookit (main-gtk.c) 40 SYS_gtk = -rdynamic -export-dynamic -DUSE_GTK $(shell pkg-config libglade-2.0 gtk+-2.0 --libs --cflags) 40 #SYS_gtk = -rdynamic -export-dynamic -DUSE_GTK $(shell pkg-config libglade-2.0 gtk+-2.0 --libs --cflags) 41 41 42 42 # Support SDL frontend trunk/src/birth.c
r169 r199 1171 1171 1172 1172 1173 #ifdef ALLOW_AUTOROLLER1174 1175 1173 s16b stat_limit[A_MAX]; 1176 1174 … … 1280 1278 } 1281 1279 1282 #endif /* ALLOW_AUTOROLLER */1283 1284 1280 /* Clean up */ 1285 1281 clear_from(10); … … 1292 1288 { 1293 1289 int col = 42; 1294 1295 #ifdef ALLOW_AUTOROLLER1296 1290 1297 1291 /* Feedback */ … … 1408 1402 /* Otherwise just get a character */ 1409 1403 else 1410 1411 #endif /* ALLOW_AUTOROLLER */1412 1413 1404 { 1414 1405 /* Get a new character */ trunk/src/cmd0.c
r153 r199 596 596 void process_command(bool no_request) 597 597 { 598 #ifdef ALLOW_REPEAT599 600 598 /* Handle repeating the last command */ 601 599 repeat_check(); 602 603 #endif /* ALLOW_REPEAT */604 600 605 601 if (!no_request) trunk/src/cmd5.c
r158 r199 299 299 cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 300 300 301 #ifdef ALLOW_REPEAT302 303 301 int result; 304 302 … … 318 316 } 319 317 } 320 321 #endif /* ALLOW_REPEAT */322 318 323 319 /* Extract spells */ … … 461 457 if (!flag) return (-1); 462 458 463 #ifdef ALLOW_REPEAT464 465 459 repeat_push(spell); 466 467 #endif /* ALLOW_REPEAT */468 460 469 461 /* Success */ trunk/src/config.h
r189 r199 36 36 37 37 38 /*39 * OPTION: for multi-user machines running the game setuid to some other40 * user (like 'games') this SAFE_SETUID option allows the program to drop41 * its privileges when saving files that allow for user specified pathnames.42 * This lets the game be installed system wide without major security43 * concerns. There should not be any side effects on any machines.44 *45 * This will handle "gids" correctly once the permissions are set right.46 */47 #define SAFE_SETUID48 49 50 /*51 * This flag enables the "POSIX" methods for "SAFE_SETUID".52 */53 #ifdef _POSIX_SAVED_IDS54 # define SAFE_SETUID_POSIX55 #endif56 57 58 59 38 60 39 /* … … 88 67 */ 89 68 #define ALLOW_MACROS 90 91 92 /*93 * OPTION: Allow characteres to be "auto-rolled"94 */95 #define ALLOW_AUTOROLLER96 69 97 70 … … 124 97 125 98 126 /*127 * OPTION: Allow repeating of last command.128 */129 #define ALLOW_REPEAT130 131 132 /*133 * OPTION: Handle signals134 */135 #define HANDLE_SIGNALS136 137 99 138 100 /* … … 149 111 #define MONSTER_FLOW 150 112 151 152 /*153 * OPTION: Maximum flow depth when using "MONSTER_FLOW"154 */155 #define MONSTER_FLOW_DEPTH 32156 113 157 114 … … 208 165 209 166 210 /*211 * Do not handle signals212 */213 #if defined(MACINTOSH) || defined(WINDOWS)214 # undef HANDLE_SIGNALS215 #endif216 217 167 218 168 … … 263 213 264 214 265 /*266 * On multiuser systems, add the "uid" to savefile names267 */268 #ifdef SET_UID269 # define SAVEFILE_USE_UID270 #endif /* SET_UID */271 272 215 273 216 /* … … 281 224 #define FIXED_PATHS 282 225 #endif /* SET_UID */ 283 284 285 /*286 * OPTION: Capitalize the "user_name" (for "default" player name)287 * This option is only relevant on SET_UID machines.288 */289 #define CAPITALIZE_USER_NAME290 226 291 227 … … 310 246 311 247 312 /*313 * Hack -- Mach-O (native binary format of OS X) is basically a Un*x314 * but has Mac OS/Windows-like user interface315 */316 #ifdef MACH_O_CARBON317 # ifdef SAVEFILE_USE_UID318 # undef SAVEFILE_USE_UID319 # endif320 #endif321 322 248 323 249 /* … … 336 262 # undef MONSTER_FLOW 337 263 # undef DRS_SMART_OPTIONS 338 # undef GJW_RANDART339 264 # undef ALLOW_BORG 340 265 # undef ALLOW_DEBUG trunk/src/defines.h
r189 r199 1404 1404 /* Number of bytes used in squelch sub-quality array */ 1405 1405 #define SQUELCH_BYTES 6 1406 1407 1408 1409 /*** Monster AI stuff ***/ 1410 1411 /* 1412 * Maximum flow depth when using "MONSTER_FLOW" 1413 */ 1414 #define MONSTER_FLOW_DEPTH 3 1406 1415 1407 1416 trunk/src/files.c
r189 r199 2503 2503 char temp[128]; 2504 2504 2505 #if def SAVEFILE_USE_UID2505 #if defined(SET_UID) 2506 2506 /* Rename the savefile, using the player_uid and base_name */ 2507 2507 strnfmt(temp, sizeof(temp), "%d.%s", player_uid, op_ptr->base_name); trunk/src/main.c
r189 r199 294 294 player_uid = getuid(); 295 295 296 # ifdef SAFE_SETUID 297 298 # if defined(HAVE_SETEGID) || defined(SAFE_SETUID_POSIX) 296 # if defined(HAVE_SETEGID) 299 297 300 298 /* Save some info for later */ … … 302 300 player_egid = getegid(); 303 301 304 # endif /* defined(HAVE_SETEGID) || defined(SAFE_SETUID_POSIX) */ 305 306 # if 0 /* XXX XXX XXX */ 307 308 /* Redundant setting necessary in case root is running the game */ 309 /* If not root or game not setuid the following two calls do nothing */ 310 311 if (setgid(getegid()) != 0) 312 { 313 quit("setgid(): cannot set permissions correctly!"); 314 } 315 316 if (setuid(geteuid()) != 0) 317 { 318 quit("setuid(): cannot set permissions correctly!"); 319 } 320 321 # endif /* 0 */ 322 323 # endif /* SAFE_SETUID */ 302 # endif /* defined(HAVE_SETEGID) */ 324 303 325 304 #endif /* SET_UID */ trunk/src/object1.c
r175 r199 2753 2753 2754 2754 2755 #ifdef ALLOW_REPEAT2756 2757 2755 /* Get the item index */ 2758 2756 if (repeat_pull(cp)) … … 2776 2774 } 2777 2775 } 2778 2779 #endif /* ALLOW_REPEAT */2780 2776 2781 2777 … … 3410 3406 if (oops && str) msg_print(str); 3411 3407 3412 #ifdef ALLOW_REPEAT3413 3414 3408 /* Save item if available */ 3415 3409 if (item) repeat_push(*cp); 3416 3417 #endif /* ALLOW_REPEAT */3418 3410 3419 3411 /* Result */ trunk/src/signals.c
r182 r199 16 16 * are included in all such copies. Other copyrights may also apply. 17 17 */ 18 19 #ifdef HANDLE_SIGNALS 18 #include "angband.h" 19 20 #ifndef WINDOWS 20 21 21 22 #include <signal.h> trunk/src/util.c
r175 r199 2938 2938 } 2939 2939 2940 #ifdef ALLOW_REPEAT2941 2942 2940 /* Get the item index */ 2943 2941 else if ((max != 1) && repeat_pull(&amt)) … … 2946 2944 } 2947 2945 2948 #endif /* ALLOW_REPEAT */2949 2950 2946 /* Prompt if needed */ 2951 2947 else if ((max != 1)) … … 2984 2980 if (amt < 0) amt = 0; 2985 2981 2986 #ifdef ALLOW_REPEAT2987 2988 2982 if (amt) repeat_push(amt); 2989 2990 #endif /* ALLOW_REPEAT */2991 2983 2992 2984 /* Return the result */ … … 3674 3666 3675 3667 3676 #ifdef ALLOW_REPEAT3677 3678 3668 #define REPEAT_MAX 20 3679 3669 … … 3774 3764 } 3775 3765 } 3776 3777 #endif /* ALLOW_REPEAT */3778 3766 3779 3767 trunk/src/xtra2.c
r189 r199 3238 3238 cptr p; 3239 3239 3240 #ifdef ALLOW_REPEAT3241 3242 3240 if (repeat_pull(dp)) 3243 3241 { … … 3253 3251 } 3254 3252 } 3255 3256 #endif /* ALLOW_REPEAT */3257 3253 3258 3254 /* Initialize */ … … 3344 3340 (*dp) = dir; 3345 3341 3346 #ifdef ALLOW_REPEAT3347 3348 3342 repeat_push(dir); 3349 3350 #endif /* ALLOW_REPEAT */3351 3343 3352 3344 /* A "valid" direction was entered */ … … 3379 3371 cptr p; 3380 3372 3381 #ifdef ALLOW_REPEAT3382 3383 3373 if (repeat_pull(dp)) 3384 3374 { 3385 3375 return (TRUE); 3386 3376 } 3387 3388 #endif /* ALLOW_REPEAT */3389 3377 3390 3378 /* Initialize */ … … 3419 3407 (*dp) = dir; 3420 3408 3421 #ifdef ALLOW_REPEAT3422 3423 3409 repeat_push(dir); 3424 3425 #endif /* ALLOW_REPEAT */3426 3410 3427 3411 /* Success */ trunk/src/z-file.c
r193 r199 22 22 # include <sys/types.h> 23 23 # include <sys/stat.h> 24 25 # ifdef WINDOWS 26 # include <io.h> 24 #endif 25 26 #ifdef WINDOWS 27 # include <io.h> 28 #endif 29 30 31 32 /* 33 * Hack -- drop permissions 34 */ 35 void safe_setuid_drop(void) 36 { 37 #ifdef SET_UID 38 # if defined(HAVE_SETRESGID) 39 if (setresgid(-1, getgid(), -1) != 0) 40 quit("setegid(): cannot set permissions correctly!"); 41 42 # elif defined(HAVE_SETEGID) 43 44 if (setegid(getgid()) != 0) 45 quit("setegid(): cannot set permissions correctly!"); 46 47 # else 48 49 if (setgid(getgid()) != 0) 50 quit("setgid(): cannot set permissions correctly!"); 51 27 52 # endif 28 #endif 29 30 31 32 /* 33 * Hack -- drop permissions 34 */ 35 void safe_setuid_drop(void) 36 { 37 53 #endif /* SET_UID */ 54 } 55 56 57 /* 58 * Hack -- grab permissions 59 */ 60 void safe_setuid_grab(void) 61 { 38 62 #ifdef SET_UID 39 40 # ifdef SAFE_SETUID 41 42 # ifdef HAVE_SETEGID 43 44 if (setegid(getgid()) != 0) 45 { 63 # if defined(HAVE_SETRESGID) 64 if (setresgid(-1, player_egid, -1) != 0) 46 65 quit("setegid(): cannot set permissions correctly!"); 47 } 48 49 # else /* HAVE_SETEGID */ 50 51 # ifdef SAFE_SETUID_POSIX 52 53 if (setgid(getgid()) != 0) 54 { 66 67 # elif defined(HAVE_SETEGID) 68 69 if (setegid(player_egid) != 0) 70 quit("setegid(): cannot set permissions correctly!"); 71 72 # else 73 74 if (setgid(player_egid) != 0) 55 75 quit("setgid(): cannot set permissions correctly!"); 56 } 57 58 # else /* SAFE_SETUID_POSIX */ 59 60 if (setregid(getegid(), getgid()) != 0) 61 { 62 quit("setregid(): cannot set permissions correctly!"); 63 } 64 65 # endif /* SAFE_SETUID_POSIX */ 66 67 # endif /* HAVE_SETEGID */ 68 69 # endif /* SAFE_SETUID */ 70 76 77 # endif 71 78 #endif /* SET_UID */ 72 73 }74 75 76 /*77 * Hack -- grab permissions78 */79 void safe_setuid_grab(void)80 {81 82 #ifdef SET_UID83 84 # ifdef SAFE_SETUID85 86 # ifdef HAVE_SETEGID87 88 if (setegid(player_egid) != 0)89 {90 quit("setegid(): cannot set permissions correctly!");91 }92 93 # else /* HAVE_SETEGID */94 95 # ifdef SAFE_SETUID_POSIX96 97 if (setgid(player_egid) != 0)98 {99 quit("setgid(): cannot set permissions correctly!");100 }101 102 # else /* SAFE_SETUID_POSIX */103 104 if (setregid(getegid(), getgid()) != 0)105 {106 quit("setregid(): cannot set permissions correctly!");107 }108 109 # endif /* SAFE_SETUID_POSIX */110 111 # endif /* HAVE_SETEGID */112 113 # endif /* SAFE_SETUID */114 115 #endif /* SET_UID */116 117 79 } 118 80 … … 370 332 my_strcpy(buf, pw->pw_name, len); 371 333 372 #ifdef CAPITALIZE_USER_NAME 373 /* Hack -- capitalize the user name */ 374 if (islower((unsigned char)buf[0])) 375 buf[0] = toupper((unsigned char)buf[0]); 376 #endif /* CAPITALIZE_USER_NAME */ 334 /* Capitalize the user name */ 335 buf[0] = toupper((unsigned char)buf[0]); 377 336 378 337 return;
