From 063a1e19cd0cdae950450ab3df8452074b2ba90e Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 26 Jan 2020 23:00:32 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20SECURE=20=E3=81=AE?= =?utf8?q?=E3=83=97=E3=83=AA=E3=83=97=E3=83=AD=E3=82=92=E5=89=8A=E9=99=A4?= =?utf8?q?=20/=20Removed=20preprocessor=20SECURE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/floor-save.c | 30 ------------------------------ src/h-config.h | 12 ------------ src/main.c | 5 ----- src/save.c | 56 +------------------------------------------------------- src/util.h | 9 --------- 5 files changed, 1 insertion(+), 111 deletions(-) diff --git a/src/floor-save.c b/src/floor-save.c index 477d736a8..30ebc5386 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -74,14 +74,6 @@ void init_saved_floors(player_type *creature_ptr, bool force) int i; int fd = -1; BIT_FLAGS mode = 0644; - -#ifdef SET_UID -# ifdef SECURE - /* Get "games" permissions */ - beGames(); -# endif -#endif - for (i = 0; i < MAX_SAVED_FLOORS; i++) { saved_floor_type *sf_ptr = &saved_floors[i]; @@ -144,13 +136,6 @@ void init_saved_floors(player_type *creature_ptr, bool force) /* No change floor mode yet */ creature_ptr->change_floor_mode = 0; - -#ifdef SET_UID -# ifdef SECURE - /* Drop "games" permissions */ - bePlayer(); -# endif -#endif } /*! @@ -163,14 +148,6 @@ void clear_saved_floor_files(player_type *creature_ptr) { char floor_savefile[1024]; int i; - -#ifdef SET_UID -# ifdef SECURE - /* Get "games" permissions */ - beGames(); -# endif -#endif - for (i = 0; i < MAX_SAVED_FLOORS; i++) { saved_floor_type *sf_ptr = &saved_floors[i]; @@ -191,13 +168,6 @@ void clear_saved_floor_files(player_type *creature_ptr) /* Drop permissions */ safe_setuid_drop(); } - -#ifdef SET_UID -# ifdef SECURE - /* Drop "games" permissions */ - bePlayer(); -# endif -#endif } /*! diff --git a/src/h-config.h b/src/h-config.h index 5c0c4f4a1..7ef2cb0d6 100644 --- a/src/h-config.h +++ b/src/h-config.h @@ -297,18 +297,6 @@ /* - * OPTION: for the AFS distributed file system, define this to ensure that - * the program is secure with respect to the setuid code. This option has - * not been tested (to the best of my knowledge). This option may require - * some weird tricks with "player_uid" and such involving "defines". - * Note that this option used the AFS library routines Authenticate(), - * bePlayer(), beGames() to enforce the proper priviledges. - * You may need to turn "SAFE_SETUID" off to use this option. - */ -/* #define SECURE */ - - -/* * OPTION: Forbid the use of "fiddled" savefiles. As far as I can tell, * a fiddled savefile is one with an internal timestamp different from * the actual timestamp. Thus, turning this option on forbids one from diff --git a/src/main.c b/src/main.c index 2c5c95b55..401948014 100644 --- a/src/main.c +++ b/src/main.c @@ -278,11 +278,6 @@ int main(int argc, char *argv[]) /* Default permissions on files */ (void)umask(022); -# ifdef SECURE - /* Authenticate */ - Authenticate(); -# endif - #endif diff --git a/src/save.c b/src/save.c index 6551aa55d..c8c2cbf45 100644 --- a/src/save.c +++ b/src/save.c @@ -1489,17 +1489,6 @@ static bool save_player_aux(player_type *player_ptr, char *name) */ bool save_player(player_type *player_ptr) { -#ifdef SET_UID - -# ifdef SECURE - - /* Get "games" permissions */ - beGames(); - -# endif - -#endif - char safe[1024]; strcpy(safe, savefile); strcat(safe, ".new"); @@ -1563,19 +1552,7 @@ bool save_player(player_type *player_ptr) /* Success */ result = TRUE; -} - - -#ifdef SET_UID - -# ifdef SECURE - - /* Drop "games" permissions */ - bePlayer(); - -# endif - -#endif + } /* Return the result */ return result; @@ -1845,15 +1822,6 @@ void remove_loc(void) char temp[1024]; #endif /* VERIFY_SAVEFILE */ -#ifdef SET_UID -# ifdef SECURE - - /* Get "games" permissions */ - beGames(); - -# endif /* SECURE */ -#endif /* SET_UID */ - #ifdef VERIFY_SAVEFILE /* Lock on savefile */ @@ -1864,16 +1832,6 @@ void remove_loc(void) fd_kill(temp); #endif /* VERIFY_SAVEFILE */ - -#ifdef SET_UID -# ifdef SECURE - - /* Drop "games" permissions */ - bePlayer(); - -# endif /* SECURE */ -#endif /* SET_UID */ - } @@ -1934,12 +1892,6 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod char floor_savefile[1024]; if (!(mode & SLF_SECOND)) { -#ifdef SET_UID -# ifdef SECURE - /* Get "games" permissions */ - beGames(); -# endif -#endif } /* We have one file already opened */ @@ -2021,12 +1973,6 @@ bool save_floor(player_type *player_ptr, saved_floor_type *sf_ptr, BIT_FLAGS mod if (!(mode & SLF_SECOND)) { -#ifdef SET_UID -# ifdef SECURE - /* Drop "games" permissions */ - bePlayer(); -# endif -#endif } /* We have one file already opened */ diff --git a/src/util.h b/src/util.h index c8c09f3b5..909b383dd 100644 --- a/src/util.h +++ b/src/util.h @@ -17,15 +17,6 @@ #define KTRL(X) ((X) & 0x1F) #define ESCAPE '\033' - /* - * Hack -- Prepare to use the "Secure" routines - */ -#if defined(SET_UID) && defined(SECURE) -extern int PlayerUID; -# define getuid() PlayerUID -# define geteuid() PlayerUID -#endif - #define KEYMAP_MODE_ORIG 0 /*!< オリジナルキー配置 / Mode for original keyset commands */ #define KEYMAP_MODE_ROGUE 1 /*!< ローグライクキー配置 / Mode for roguelike keyset commands */ #define KEYMAP_MODES 2 /*!< キー配置の数 / Number of keymap modes */ -- 2.11.0