Changeset 39

Show
Ignore:
Timestamp:
04/09/07 19:45:27 (2 years ago)
Author:
takkaria
Message:

Remove some nonfunctional or trivial-to-hack-around options (VERIFY_SAVEFILE, VERIFY_TIMESTAMP, VERIFY_HONOR).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/config.h

    r38 r39  
    7575#endif 
    7676 
    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 from 
    83  * the actual timestamp.  Thus, turning this option on forbids one from 
    84  * copying a savefile to a different name.  Combined with disabling the 
    85  * ability to save the game without quitting, and with some method of 
    86  * stopping the user from killing the process at the tombstone screen, 
    87  * this should prevent the use of backup savefiles.  It may also stop 
    88  * 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 simply 
    95  * run another copy of the game, loading a previously saved savefile, 
    96  * and let that copy over-write the "dead" savefile later.  This option 
    97  * either locks the savefile, or creates a fake "xxx.lok" file to prevent 
    98  * the use of the savefile until the file is deleted.  Not ready yet. 
    99  */ 
    100 /* #define VERIFY_SAVEFILE */ 
    10177 
    10278 
     
    389365 * OPTION: Person to bother if something goes wrong. 
    390366 */ 
    391 #define MAINTAINER      "rr9@thangorodrim.net
     367#define MAINTAINER      "angbandmaint@gmail.com
    392368 
    393369 
     
    458434 
    459435/* 
    460  * OPTION: Attempt to prevent all "cheating" 
    461  */ 
    462 /* #define VERIFY_HONOR */ 
    463  
    464  
    465 /* 
    466  * React to the "VERIFY_HONOR" flag 
    467  */ 
    468 #ifdef VERIFY_HONOR 
    469 # define VERIFY_SAVEFILE 
    470 # define VERIFY_CHECKSUMS 
    471 # define VERIFY_TIMESTAMP 
    472 #endif 
    473  
    474  
    475 /* 
    476436 * Allow the Borg to use graphics. 
    477437 */ 
  • trunk/src/dungeon.c

    r38 r39  
    17801780                } 
    17811781 
    1782 #ifndef VERIFY_SAVEFILE 
    1783  
    17841782                /* Hack -- Save and don't quit */ 
    17851783                case KTRL('S'): 
     
    17881786                        break; 
    17891787                } 
    1790  
    1791 #endif 
    17921788 
    17931789                /* Save and quit */ 
  • trunk/src/load.c

    r24 r39  
    20892089        byte vvv[4]; 
    20902090 
    2091 #ifdef VERIFY_TIMESTAMP 
    2092         struct stat     statbuf; 
    2093 #endif /* VERIFY_TIMESTAMP */ 
    2094  
    20952091        cptr what = "generic"; 
    20962092 
     
    21302126 
    21312127 
    2132 #ifdef VERIFY_SAVEFILE 
    2133  
    2134         /* Verify savefile usage */ 
     2128        /* Okay */ 
    21352129        if (!err) 
    21362130        { 
    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  
    21452131                /* Grab permissions */ 
    21462132                safe_setuid_grab(); 
    21472133 
    2148                 /* Check for lock */ 
    2149                 fkk = my_fopen(temp, "r"); 
     2134                /* Open the savefile */ 
     2135                fd = fd_open(savefile, O_RDONLY); 
    21502136 
    21512137                /* Drop permissions */ 
    21522138                safe_setuid_drop(); 
    21532139 
    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  
    21992140                /* No file */ 
    22002141                if (fd < 0) err = -1; 
     
    22072148        if (!err) 
    22082149        { 
    2209  
    2210 #ifdef VERIFY_TIMESTAMP 
    2211  
    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  
    22232150                /* Read the first four bytes */ 
    22242151                if (fd_read(fd, (char*)(vvv), sizeof(vvv))) err = -1; 
     
    22732200        } 
    22742201 
    2275 #ifdef VERIFY_TIMESTAMP 
    2276         /* 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  
    22922202 
    22932203        /* Okay */ 
     
    23462256 
    23472257 
    2348 #ifdef VERIFY_SAVEFILE 
    2349  
    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  
    23722258        /* Message */ 
    23732259        msg_format("Error (%s) reading %d.%d.%d savefile.", 
  • trunk/src/main.c

    r38 r39  
    248248                } 
    249249 
    250 #ifdef VERIFY_SAVEFILE 
    251  
    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  
    262250                case 'b': 
    263251                { 
     
    287275                        break; 
    288276                } 
    289  
    290 #endif /* VERIFY_SAVEFILE */ 
    291277 
    292278#endif /* FIXED_PATHS */ 
  • trunk/src/save.c

    r24 r39  
    10991099                character_loaded = TRUE; 
    11001100 
    1101 #ifdef VERIFY_SAVEFILE 
    1102  
    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  
    11181101                /* Success */ 
    11191102                result = TRUE;