Changeset 199

Show
Ignore:
Timestamp:
06/21/07 19:54:51 (1 year ago)
Author:
takkaria
Message:

Fix nits in #159.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/configure.ac

    r198 r199  
    190190AC_C_CONST 
    191191AC_TYPE_SIGNAL 
    192 AC_CHECK_FUNCS([mkstemp setegid can_change_color]) 
     192AC_CHECK_FUNCS([mkstemp setresgid setegid can_change_color]) 
    193193 
    194194 
  • trunk/src/Makefile.std

    r197 r199  
    3838 
    3939# 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) 
    4141 
    4242# Support SDL frontend 
  • trunk/src/birth.c

    r169 r199  
    11711171 
    11721172 
    1173 #ifdef ALLOW_AUTOROLLER 
    1174  
    11751173        s16b stat_limit[A_MAX]; 
    11761174 
     
    12801278        } 
    12811279 
    1282 #endif /* ALLOW_AUTOROLLER */ 
    1283  
    12841280        /* Clean up */ 
    12851281        clear_from(10); 
     
    12921288        { 
    12931289                int col = 42; 
    1294  
    1295 #ifdef ALLOW_AUTOROLLER 
    12961290 
    12971291                /* Feedback */ 
     
    14081402                /* Otherwise just get a character */ 
    14091403                else 
    1410  
    1411 #endif /* ALLOW_AUTOROLLER */ 
    1412  
    14131404                { 
    14141405                        /* Get a new character */ 
  • trunk/src/cmd0.c

    r153 r199  
    596596void process_command(bool no_request) 
    597597{ 
    598 #ifdef ALLOW_REPEAT 
    599  
    600598        /* Handle repeating the last command */ 
    601599        repeat_check(); 
    602  
    603 #endif /* ALLOW_REPEAT */ 
    604600 
    605601        if (!no_request) 
  • trunk/src/cmd5.c

    r158 r199  
    299299        cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer"); 
    300300 
    301 #ifdef ALLOW_REPEAT 
    302  
    303301        int result; 
    304302 
     
    318316                } 
    319317        } 
    320  
    321 #endif /* ALLOW_REPEAT */ 
    322318 
    323319        /* Extract spells */ 
     
    461457        if (!flag) return (-1); 
    462458 
    463 #ifdef ALLOW_REPEAT 
    464  
    465459        repeat_push(spell); 
    466  
    467 #endif /* ALLOW_REPEAT */ 
    468460 
    469461        /* Success */ 
  • trunk/src/config.h

    r189 r199  
    3636 
    3737 
    38 /* 
    39  * OPTION: for multi-user machines running the game setuid to some other 
    40  * user (like 'games') this SAFE_SETUID option allows the program to drop 
    41  * its privileges when saving files that allow for user specified pathnames. 
    42  * This lets the game be installed system wide without major security 
    43  * 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_SETUID 
    48  
    49  
    50 /* 
    51  * This flag enables the "POSIX" methods for "SAFE_SETUID". 
    52  */ 
    53 #ifdef _POSIX_SAVED_IDS 
    54 # define SAFE_SETUID_POSIX 
    55 #endif 
    56  
    57  
    58  
    5938 
    6039/* 
     
    8867 */ 
    8968#define ALLOW_MACROS 
    90  
    91  
    92 /* 
    93  * OPTION: Allow characteres to be "auto-rolled" 
    94  */ 
    95 #define ALLOW_AUTOROLLER 
    9669 
    9770 
     
    12497 
    12598 
    126 /* 
    127  * OPTION: Allow repeating of last command. 
    128  */ 
    129 #define ALLOW_REPEAT 
    130  
    131  
    132 /* 
    133  * OPTION: Handle signals 
    134  */ 
    135 #define HANDLE_SIGNALS 
    136  
    13799 
    138100/* 
     
    149111#define MONSTER_FLOW 
    150112 
    151  
    152 /* 
    153  * OPTION: Maximum flow depth when using "MONSTER_FLOW" 
    154  */ 
    155 #define MONSTER_FLOW_DEPTH 32 
    156113 
    157114 
     
    208165 
    209166 
    210 /* 
    211  * Do not handle signals 
    212  */ 
    213 #if defined(MACINTOSH) || defined(WINDOWS) 
    214 # undef HANDLE_SIGNALS 
    215 #endif 
    216  
    217167 
    218168 
     
    263213 
    264214 
    265 /* 
    266  * On multiuser systems, add the "uid" to savefile names 
    267  */ 
    268 #ifdef SET_UID 
    269 # define SAVEFILE_USE_UID 
    270 #endif /* SET_UID */ 
    271  
    272215 
    273216/* 
     
    281224#define FIXED_PATHS 
    282225#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_NAME 
    290226 
    291227 
     
    310246 
    311247 
    312 /* 
    313  * Hack -- Mach-O (native binary format of OS X) is basically a Un*x 
    314  * but has Mac OS/Windows-like user interface 
    315  */ 
    316 #ifdef MACH_O_CARBON 
    317 # ifdef SAVEFILE_USE_UID 
    318 #  undef SAVEFILE_USE_UID 
    319 # endif 
    320 #endif 
    321  
    322248 
    323249/* 
     
    336262# undef MONSTER_FLOW 
    337263# undef DRS_SMART_OPTIONS 
    338 # undef GJW_RANDART 
    339264# undef ALLOW_BORG 
    340265# undef ALLOW_DEBUG 
  • trunk/src/defines.h

    r189 r199  
    14041404/* Number of bytes used in squelch sub-quality array */ 
    14051405#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 
    14061415 
    14071416 
  • trunk/src/files.c

    r189 r199  
    25032503                char temp[128]; 
    25042504 
    2505 #ifdef SAVEFILE_USE_UID 
     2505#if defined(SET_UID) 
    25062506                /* Rename the savefile, using the player_uid and base_name */ 
    25072507                strnfmt(temp, sizeof(temp), "%d.%s", player_uid, op_ptr->base_name); 
  • trunk/src/main.c

    r189 r199  
    294294        player_uid = getuid(); 
    295295 
    296 # ifdef SAFE_SETUID 
    297  
    298 #  if defined(HAVE_SETEGID) || defined(SAFE_SETUID_POSIX) 
     296# if defined(HAVE_SETEGID) 
    299297 
    300298        /* Save some info for later */ 
     
    302300        player_egid = getegid(); 
    303301 
    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) */ 
    324303 
    325304#endif /* SET_UID */ 
  • trunk/src/object1.c

    r175 r199  
    27532753 
    27542754 
    2755 #ifdef ALLOW_REPEAT 
    2756  
    27572755        /* Get the item index */ 
    27582756        if (repeat_pull(cp)) 
     
    27762774                } 
    27772775        } 
    2778  
    2779 #endif /* ALLOW_REPEAT */ 
    27802776 
    27812777 
     
    34103406        if (oops && str) msg_print(str); 
    34113407 
    3412 #ifdef ALLOW_REPEAT 
    3413  
    34143408        /* Save item if available */ 
    34153409        if (item) repeat_push(*cp); 
    3416  
    3417 #endif /* ALLOW_REPEAT */ 
    34183410 
    34193411        /* Result */ 
  • trunk/src/signals.c

    r182 r199  
    1616 *    are included in all such copies.  Other copyrights may also apply. 
    1717 */ 
    18  
    19 #ifdef HANDLE_SIGNALS 
     18#include "angband.h" 
     19 
     20#ifndef WINDOWS 
    2021 
    2122#include <signal.h> 
  • trunk/src/util.c

    r175 r199  
    29382938        } 
    29392939 
    2940 #ifdef ALLOW_REPEAT 
    2941  
    29422940        /* Get the item index */ 
    29432941        else if ((max != 1) && repeat_pull(&amt)) 
     
    29462944        } 
    29472945 
    2948 #endif /* ALLOW_REPEAT */ 
    2949  
    29502946        /* Prompt if needed */ 
    29512947        else if ((max != 1)) 
     
    29842980        if (amt < 0) amt = 0; 
    29852981 
    2986 #ifdef ALLOW_REPEAT 
    2987  
    29882982        if (amt) repeat_push(amt); 
    2989  
    2990 #endif /* ALLOW_REPEAT */ 
    29912983 
    29922984        /* Return the result */ 
     
    36743666 
    36753667 
    3676 #ifdef ALLOW_REPEAT 
    3677  
    36783668#define REPEAT_MAX 20 
    36793669 
     
    37743764        } 
    37753765} 
    3776  
    3777 #endif /* ALLOW_REPEAT */ 
    37783766 
    37793767 
  • trunk/src/xtra2.c

    r189 r199  
    32383238        cptr p; 
    32393239 
    3240 #ifdef ALLOW_REPEAT 
    3241  
    32423240        if (repeat_pull(dp)) 
    32433241        { 
     
    32533251                } 
    32543252        } 
    3255  
    3256 #endif /* ALLOW_REPEAT */ 
    32573253 
    32583254        /* Initialize */ 
     
    33443340        (*dp) = dir; 
    33453341 
    3346 #ifdef ALLOW_REPEAT 
    3347  
    33483342        repeat_push(dir); 
    3349  
    3350 #endif /* ALLOW_REPEAT */ 
    33513343 
    33523344        /* A "valid" direction was entered */ 
     
    33793371        cptr p; 
    33803372 
    3381 #ifdef ALLOW_REPEAT 
    3382  
    33833373        if (repeat_pull(dp)) 
    33843374        { 
    33853375                return (TRUE); 
    33863376        } 
    3387  
    3388 #endif /* ALLOW_REPEAT */ 
    33893377 
    33903378        /* Initialize */ 
     
    34193407        (*dp) = dir; 
    34203408 
    3421 #ifdef ALLOW_REPEAT 
    3422  
    34233409        repeat_push(dir); 
    3424  
    3425 #endif /* ALLOW_REPEAT */ 
    34263410 
    34273411        /* Success */ 
  • trunk/src/z-file.c

    r193 r199  
    2222# include <sys/types.h> 
    2323# 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 */ 
     35void 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 
    2752# 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 */ 
     60void safe_setuid_grab(void) 
     61
    3862#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) 
    4665                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) 
    5575                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 
    7178#endif /* SET_UID */ 
    72  
    73 } 
    74  
    75  
    76 /* 
    77  * Hack -- grab permissions 
    78  */ 
    79 void safe_setuid_grab(void) 
    80 { 
    81  
    82 #ifdef SET_UID 
    83  
    84 # ifdef SAFE_SETUID 
    85  
    86 #  ifdef HAVE_SETEGID 
    87  
    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_POSIX 
    96  
    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  
    11779} 
    11880 
     
    370332                my_strcpy(buf, pw->pw_name, len); 
    371333 
    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]); 
    377336 
    378337                return;