Changeset 39
- Timestamp:
- 04/09/07 19:45:27 (2 years ago)
- Files:
-
- trunk/src/config.h (modified) (3 diffs)
- trunk/src/dungeon.c (modified) (2 diffs)
- trunk/src/load.c (modified) (5 diffs)
- trunk/src/main.c (modified) (2 diffs)
- trunk/src/save.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/config.h
r38 r39 75 75 #endif 76 76 77 78 79 80 /*81 * OPTION: Forbid the use of "fiddled" savefiles. As far as I can tell,82 * a fiddled savefile is one with an internal timestamp different from83 * the actual timestamp. Thus, turning this option on forbids one from84 * copying a savefile to a different name. Combined with disabling the85 * ability to save the game without quitting, and with some method of86 * stopping the user from killing the process at the tombstone screen,87 * this should prevent the use of backup savefiles. It may also stop88 * the use of savefiles from other platforms, so be careful.89 */90 /* #define VERIFY_TIMESTAMP */91 92 93 /*94 * OPTION: Forbid the "savefile over-write" cheat, in which you simply95 * run another copy of the game, loading a previously saved savefile,96 * and let that copy over-write the "dead" savefile later. This option97 * either locks the savefile, or creates a fake "xxx.lok" file to prevent98 * the use of the savefile until the file is deleted. Not ready yet.99 */100 /* #define VERIFY_SAVEFILE */101 77 102 78 … … 389 365 * OPTION: Person to bother if something goes wrong. 390 366 */ 391 #define MAINTAINER " rr9@thangorodrim.net"367 #define MAINTAINER "angbandmaint@gmail.com" 392 368 393 369 … … 458 434 459 435 /* 460 * OPTION: Attempt to prevent all "cheating"461 */462 /* #define VERIFY_HONOR */463 464 465 /*466 * React to the "VERIFY_HONOR" flag467 */468 #ifdef VERIFY_HONOR469 # define VERIFY_SAVEFILE470 # define VERIFY_CHECKSUMS471 # define VERIFY_TIMESTAMP472 #endif473 474 475 /*476 436 * Allow the Borg to use graphics. 477 437 */ trunk/src/dungeon.c
r38 r39 1780 1780 } 1781 1781 1782 #ifndef VERIFY_SAVEFILE1783 1784 1782 /* Hack -- Save and don't quit */ 1785 1783 case KTRL('S'): … … 1788 1786 break; 1789 1787 } 1790 1791 #endif1792 1788 1793 1789 /* Save and quit */ trunk/src/load.c
r24 r39 2089 2089 byte vvv[4]; 2090 2090 2091 #ifdef VERIFY_TIMESTAMP2092 struct stat statbuf;2093 #endif /* VERIFY_TIMESTAMP */2094 2095 2091 cptr what = "generic"; 2096 2092 … … 2130 2126 2131 2127 2132 #ifdef VERIFY_SAVEFILE 2133 2134 /* Verify savefile usage */ 2128 /* Okay */ 2135 2129 if (!err) 2136 2130 { 2137 FILE *fkk;2138 2139 char temp[1024];2140 2141 /* Extract name of lock file */2142 my_strcpy(temp, savefile, sizeof(temp));2143 my_strcat(temp, ".lok", sizeof(temp));2144 2145 2131 /* Grab permissions */ 2146 2132 safe_setuid_grab(); 2147 2133 2148 /* Check for lock*/2149 f kk = my_fopen(temp, "r");2134 /* Open the savefile */ 2135 fd = fd_open(savefile, O_RDONLY); 2150 2136 2151 2137 /* Drop permissions */ 2152 2138 safe_setuid_drop(); 2153 2139 2154 /* Oops, lock exists */2155 if (fkk)2156 {2157 /* Close the file */2158 my_fclose(fkk);2159 2160 /* Message */2161 msg_print("Savefile is currently in use.");2162 message_flush();2163 2164 /* Oops */2165 return (FALSE);2166 }2167 2168 /* Grab permissions */2169 safe_setuid_grab();2170 2171 /* Create a lock file */2172 fkk = my_fopen(temp, "w");2173 2174 /* Drop permissions */2175 safe_setuid_drop();2176 2177 /* Dump a line of info */2178 fprintf(fkk, "Lock file for savefile '%s'\n", savefile);2179 2180 /* Close the lock file */2181 my_fclose(fkk);2182 }2183 2184 #endif /* VERIFY_SAVEFILE */2185 2186 2187 /* Okay */2188 if (!err)2189 {2190 /* Grab permissions */2191 safe_setuid_grab();2192 2193 /* Open the savefile */2194 fd = fd_open(savefile, O_RDONLY);2195 2196 /* Drop permissions */2197 safe_setuid_drop();2198 2199 2140 /* No file */ 2200 2141 if (fd < 0) err = -1; … … 2207 2148 if (!err) 2208 2149 { 2209 2210 #ifdef VERIFY_TIMESTAMP2211 2212 /* Grab permissions */2213 safe_setuid_grab();2214 2215 /* Get the timestamp */2216 (void)fstat(fd, &statbuf);2217 2218 /* Drop permissions */2219 safe_setuid_drop();2220 2221 #endif /* VERIFY_TIMESTAMP */2222 2223 2150 /* Read the first four bytes */ 2224 2151 if (fd_read(fd, (char*)(vvv), sizeof(vvv))) err = -1; … … 2273 2200 } 2274 2201 2275 #ifdef VERIFY_TIMESTAMP2276 /* Verify timestamp */2277 if (!err && !arg_wizard)2278 {2279 /* Hack -- Verify the timestamp */2280 if (sf_when > (statbuf.st_ctime + 100) ||2281 sf_when < (statbuf.st_ctime - 100))2282 {2283 /* Message */2284 what = "Invalid timestamp";2285 2286 /* Oops */2287 err = -1;2288 }2289 }2290 #endif /* VERIFY_TIMESTAMP */2291 2292 2202 2293 2203 /* Okay */ … … 2346 2256 2347 2257 2348 #ifdef VERIFY_SAVEFILE2349 2350 /* Verify savefile usage */2351 if (TRUE)2352 {2353 char temp[1024];2354 2355 /* Extract name of lock file */2356 my_strcpy(temp, savefile, sizeof(temp));2357 my_strcat(temp, ".lok", sizeof(temp));2358 2359 /* Grab permissions */2360 safe_setuid_grab();2361 2362 /* Remove lock */2363 fd_kill(temp);2364 2365 /* Drop permissions */2366 safe_setuid_drop();2367 }2368 2369 #endif /* VERIFY_SAVEFILE */2370 2371 2372 2258 /* Message */ 2373 2259 msg_format("Error (%s) reading %d.%d.%d savefile.", trunk/src/main.c
r38 r39 248 248 } 249 249 250 #ifdef VERIFY_SAVEFILE251 252 case 'b':253 case 'd':254 case 'e':255 case 's':256 {257 quit_fmt("Restricted option '-d%s'", info);258 }259 260 #else /* VERIFY_SAVEFILE */261 262 250 case 'b': 263 251 { … … 287 275 break; 288 276 } 289 290 #endif /* VERIFY_SAVEFILE */291 277 292 278 #endif /* FIXED_PATHS */ trunk/src/save.c
r24 r39 1099 1099 character_loaded = TRUE; 1100 1100 1101 #ifdef VERIFY_SAVEFILE1102 1103 /* Lock on savefile */1104 my_strcpy(temp, savefile, sizeof(temp));1105 my_strcat(temp, ".lok", sizeof(temp));1106 1107 /* Grab permissions */1108 safe_setuid_grab();1109 1110 /* Remove lock file */1111 fd_kill(temp);1112 1113 /* Drop permissions */1114 safe_setuid_drop();1115 1116 #endif /* VERIFY_SAVEFILE */1117 1118 1101 /* Success */ 1119 1102 result = TRUE;
