OSDN Git Service

pernの掲示板で報告されていた、safe_setuid_drop();と safe_setuid_grab(); を
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Wed, 23 Jan 2002 10:18:26 +0000 (10:18 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Wed, 23 Jan 2002 10:18:26 +0000 (10:18 +0000)
ちゃんとしたところで呼ぶように修正。

Changelogs
src/cmd4.c
src/files.c
src/wizard1.c

index d2082a2..a2feed6 100644 (file)
@@ -1,5 +1,23 @@
 2002-01-22  habu  <habu@akiru>
 
+       * src/cave.c, src/dungeon.c, src/externs.h, src/melee2.c:
+       ¥â¥ó¥¹¥¿¡¼¤ÎÄÉÀץ롼¥Á¥ó´Ø·¸¤òO¤ò»²¹Í¤ËÂçÉý¤ËÊѹ¹¡£¤«¤Ê¤ê¤Î½èÍý®ÅÙ¥¢¥Ã¥×¤Ë·Ò¤¬¤ë¤Ï¤º¡£
+
+2002-01-22  Takeshi Mogami  <mogami@akiru>
+
+       * lib/help/jobjects.hlp, lib/help/jobjects.txt:
+       ¥Õ¥¡¥¤¥ëÄɲäÎÄɲÃ
+
+       * lib/help/readme.txt:
+       Á°¡¢¡Ö´Ö°ã¤Ã¤Æreadme.txt¤òhelp¥Ç¥£¥ì¥¯¥È¥ê¤Ëadd¤·¤¿¤Þ¤Þ¤À¤Ã¤¿¡×¤È»×¤Ã¤Æºï½ü¤·¤¿¤¬¡¢
+       ´ª°ã¤¤¤À¤Ã¤¿¤Î¤ÇÉü³è¡£
+
+       * lib/help/jbldg.txt, lib/help/jcharattr.hlp, lib/help/jcharattr.txt, lib/help/jcommand.hlp, lib/help/jcommand.txt, lib/help/jcommand0.txt, lib/help/jcommdesc.hlp, lib/help/jcommdesc.txt, lib/help/jdefend.hlp, lib/help/jdefend.txt, lib/help/jdungeon.hlp, lib/help/jdungeon.txt, lib/help/jgambling.txt, lib/help/jgeneral.hlp, lib/help/jgeneral.txt, lib/help/jhelp.hlp, lib/help/jhelpinfo.txt, lib/help/jmagic.hlp, lib/help/jmagic.txt, lib/help/jmonster.hlp, lib/help/jmonster.txt, lib/help/joption.hlp, lib/help/joption.txt, lib/help/jplaying.txt, lib/help/jpref.hlp, lib/help/jpref.txt, lib/help/jspecial.hlp, lib/help/jtang.txt, lib/help/jtown.hlp, lib/help/jtown.txt, lib/help/jversion.txt, src/files.c, Changelogs, lib/help/Makefile.am, lib/help/j_general.txt, lib/help/j_item1.txt, lib/help/j_item2.txt, lib/help/j_name.txt, lib/help/j_trans.txt, lib/help/japanese.txt, lib/help/jattack.hlp, lib/help/jattack.txt, lib/help/jbirth.hlp, lib/help/jbirth.txt:
+       ÆüËܸìÈǤÎZ240¥Ø¥ë¥×¤ò¸µ¤ËÊѶòÈÚÅܥإë¥×¤òºîÀ®¡£
+       ¤Þ¤Àjmagic¤Ê¤É¡¢°ìÉô̤´°À®¡£
+
+2002-01-22  habu  <habu@akiru>
+
        * src/cmd5.c, src/externs.h, src/spells2.c:
        ¥Ú¥Ã¥ÈÇúÇˤÎËâË¡¤Ç¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤òÇ˲õ¤Ç¤­¤Ê¤¤¤è¤¦¤Ë½¤Àµ¡£
 
index e591776..1d23e44 100644 (file)
@@ -133,6 +133,9 @@ static FILE *open_auto_dump(cptr buf, cptr mark, int *line)
 
        char header_mark_str[80];
 
+       /* Drop priv's */
+       safe_setuid_drop();
+
        sprintf(header_mark_str, auto_dump_header, mark);
 
        /* Remove old macro dumps */
@@ -149,6 +152,10 @@ static FILE *open_auto_dump(cptr buf, cptr mark, int *line)
                msg_format("Failed to open %s.", buf);
 #endif
                msg_print(NULL);
+
+               /* Grab priv's */
+               safe_setuid_grab();
+               
                return NULL;
        }
 
@@ -190,6 +197,9 @@ static void close_auto_dump(FILE *fff, cptr mark, int line_num)
 
        my_fclose(fff);
 
+       /* Grab priv's */
+       safe_setuid_grab();
+               
        return;
 }
 
@@ -252,6 +262,9 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
        sprintf(file_name,"playrec-%s.txt",savefile_base);
 #endif
 
+       /* Hack -- drop permissions */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
 
@@ -261,7 +274,10 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
        fff = my_fopen(buf, "a");
 
        /* Failure */
-       if (!fff) {
+       if (!fff)
+       {
+               /* Hack -- grab permissions */
+               safe_setuid_grab();
 #ifdef JP
                msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£¥×¥ì¥¤µ­Ï¿¤ò°ì»þÄä»ß¤·¤Þ¤¹¡£", buf);
 #else
@@ -655,6 +671,9 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
 
        my_fclose(fff);
 
+       /* Hack -- grab permissions */
+       safe_setuid_grab();
+
        if (do_level) write_level = FALSE;
 
        return (0);
@@ -741,6 +760,9 @@ static void do_cmd_disp_nikki(void)
        sprintf(file_name,"playrec-%s.txt",savefile_base);
 #endif
 
+       /* Hack -- drop permissions */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
 
@@ -760,6 +782,9 @@ static void do_cmd_disp_nikki(void)
 
        /* Display the file contents */
        show_file(FALSE, buf, nikki_title, -1, 0);
+
+       /* Hack -- grab permissions */
+       safe_setuid_grab();
 }
 
 static void do_cmd_bunshou(void)
@@ -822,6 +847,9 @@ static void do_cmd_erase_nikki(void)
        sprintf(file_name,"playrec-%s.txt",savefile_base);
 #endif
 
+       /* Hack -- drop permissions */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
 
@@ -844,6 +872,9 @@ static void do_cmd_erase_nikki(void)
 #endif
        }
        msg_print(NULL);
+
+       /* Hack -- grab permissions */
+       safe_setuid_grab();
 }
 
 #if 0
@@ -2827,15 +2858,9 @@ void do_cmd_macros(void)
                        /* Ask for a file */
                        if (!askfor_aux(tmp, 80)) continue;
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Dump the macros */
                        (void)macro_dump(tmp);
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Prompt */
 #ifdef JP
                        msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
@@ -3020,15 +3045,9 @@ void do_cmd_macros(void)
                        /* Ask for a file */
                        if (!askfor_aux(tmp, 80)) continue;
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Dump the macros */
                        (void)keymap_dump(tmp);
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Prompt */
 #ifdef JP
                        msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
@@ -3384,16 +3403,10 @@ void do_cmd_visuals(void)
                        /* Build the filename */
                        path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
                        if (!fff) continue;
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Start dumping */
 #ifdef JP
                        fprintf(fff, "\n# ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
@@ -3463,16 +3476,10 @@ void do_cmd_visuals(void)
                        /* Build the filename */
                        path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
                        if (!fff) continue;
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Start dumping */
 #ifdef JP
                        fprintf(fff, "\n# ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
@@ -3542,16 +3549,10 @@ void do_cmd_visuals(void)
                        /* Build the filename */
                        path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
                        if (!fff) continue;
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Start dumping */
 #ifdef JP
                        fprintf(fff, "\n# ÃÏ·Á¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
@@ -4014,16 +4015,10 @@ void do_cmd_colors(void)
                        /* Build the filename */
                        path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
 
-                       /* Drop priv's */
-                       safe_setuid_drop();
-
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
                        if (!fff) continue;
 
-                       /* Grab priv's */
-                       safe_setuid_grab();
-
                        /* Start dumping */
 #ifdef JP
                        fprintf(fff, "\n# ¥«¥é¡¼¤ÎÀßÄê\n\n");
@@ -4603,6 +4598,9 @@ void do_cmd_load_screen(void)
        char buf[1024];
 
 
+       /* Hack -- drop permissions */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
 
@@ -4678,6 +4676,9 @@ void do_cmd_load_screen(void)
        /* Close it */
        my_fclose(fff);
 
+       /* Hack -- grab permissions */
+       safe_setuid_grab();
+               
 
        /* Message */
 #ifdef JP
@@ -5041,15 +5042,9 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
 
-       /* Hack -- drop permissions */
-       safe_setuid_drop();
-
        /* Append to the file */
        fff = my_fopen(filename, "w");
 
-       /* Hack -- grab permissions */
-       safe_setuid_grab();
-
        /* Oops */
        if (!fff) {
                if (message) {
@@ -5060,12 +5055,13 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 #endif
                    msg_print(NULL);
                }
-           return;
+               
+               return;
        }
 
        /* Save the screen */
        if (message)
-       screen_save();
+               screen_save();
 
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, "htmldump.prf");
@@ -5135,7 +5131,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        if (!tmpfff) {
                for (i = 0; html_foot[i]; i++)
                        fprintf(fff, html_foot[i]);
-               }
+       }
        else {
                rewind(tmpfff);
                yomikomu = 0;
@@ -5171,7 +5167,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 
        /* Restore the screen */
        if (message)
-       screen_load();
+               screen_load();
 }
 
 /*
@@ -5193,7 +5189,13 @@ void do_cmd_save_screen_html(void)
 
        msg_print(NULL);
 
+       /* Hack -- drop permissions */
+       safe_setuid_drop();
+
        do_cmd_save_screen_html_aux(buf, 1);
+
+       /* Hack -- grab permissions */
+       safe_setuid_grab();
 }
 
 
@@ -5236,30 +5238,30 @@ void do_cmd_save_screen(void)
                char buf[1024];
 
 
+               /* Hack -- drop permissions */
+               safe_setuid_drop();
+
                /* Build the filename */
                path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
 
                /* File type is "TEXT" */
                FILE_TYPE(FILE_TYPE_TEXT);
 
-               /* Hack -- drop permissions */
-               safe_setuid_drop();
-
                /* Append to the file */
                fff = my_fopen(buf, "w");
 
-               /* Hack -- grab permissions */
-               safe_setuid_grab();
-
                /* Oops */
-               if (!fff) {
+               if (!fff)
+               {
+                       /* Hack -- grab permissions */
+                       safe_setuid_grab();
 #ifdef JP
-                   msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
+                       msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
 #else
-                   msg_format("Failed to open file %s.", buf);
+                       msg_format("Failed to open file %s.", buf);
 #endif
-                   msg_print(NULL);
-                   return;
+                       msg_print(NULL);
+                       return;
                }
 
 
@@ -5318,6 +5320,8 @@ void do_cmd_save_screen(void)
                /* Close it */
                my_fclose(fff);
 
+               /* Hack -- grab permissions */
+               safe_setuid_grab();
 
                /* Message */
 #ifdef JP
index 32034fa..49521fa 100644 (file)
@@ -4859,10 +4859,6 @@ errr file_character(cptr name, bool full)
        /* Open the non-existing file */
        if (fd < 0) fff = my_fopen(buf, "w");
 
-       /* Grab priv's */
-       safe_setuid_grab();
-
-
        /* Invalid file */
        if (!fff)
        {
@@ -4884,6 +4880,8 @@ msg_format("
        /* Close it */
        my_fclose(fff);
 
+       /* Grab priv's */
+       safe_setuid_grab();
 
        /* Message */
 #ifdef JP
@@ -5305,10 +5303,11 @@ msg_format("'%s'
                /* Show a general "title" */
                if (show_version)
                {
+                       prt(format(
 #ifdef JP
-prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
+                               "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
 #else
-               prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
+                               "[Hengband %d.%d.%d, %s, Line %d/%d]",
 #endif
 
                           FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
@@ -5316,12 +5315,13 @@ prt(format("[
                }
                else
                {
+                       prt(format(
 #ifdef JP
-prt(format("[%s, %d/%d]",
+                               "[%s, %d/%d]",
 #else
-                       prt(format("[%s, Line %d/%d]",
+                               "[%s, Line %d/%d]",
 #endif
-                                  caption, line, size), 0, 0);
+                               caption, line, size), 0, 0);
                }
 
                /* Prompt -- menu screen */
@@ -5485,32 +5485,6 @@ strcpy(tmp, "jhelp.hlp");
                        if (line < 0) line = ((size-1)/20)*20;
                }
 
-#ifdef JP_FALSE
-               /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
-               /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
-
-               /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
-               if (menu && (k == 'c' || k == 'C'))
-               {
-                       char tmp[80];
-                       switch (rogue_like_commands)
-                       {
-                               case TRUE:
-                               {
-                                       strcpy(tmp, "j_com_r.txt");
-                                       if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
-                                       break;
-                               }
-                               case FALSE:
-                               {
-                                       strcpy(tmp, "j_com_o.txt");
-                                       if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
-                                       break;
-                               }
-                       }
-               }
-
-#endif
                /* Recurse on numbers */
                if (menu)
                {
@@ -5537,27 +5511,23 @@ strcpy(tmp, "jhelp.hlp");
                        strcpy (xtmp, "");
 
 #ifdef JP
-if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
+                       if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
 #else
-                       if (get_string("File name: ", xtmp, 80))
+                       if (!get_string("File name: ", xtmp, 80))
 #endif
-
-                       {
-                               if (xtmp[0] && (xtmp[0] != ' '))
-                               {
-                               }
-                       }
-                       else
                        {
                                continue;
                        }
+                       /* Close it */
+                       my_fclose(fff);
+
+                        /* Drop priv's */
+                       safe_setuid_drop();
 
                        /* Build the filename */
                        path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
 
-                       /* Close it */
-                       my_fclose(fff);
-
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
 
@@ -5567,7 +5537,7 @@ if (get_string("
                        if (!(fff && ffp))
                        {
 #ifdef JP
-msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
+msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
 #else
                                msg_print("Failed to open file.");
 #endif
@@ -5587,6 +5557,9 @@ msg_print("
                        my_fclose(fff);
                        my_fclose(ffp);
 
+                       /* Grab priv's */
+                       safe_setuid_grab();
+
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
                }
index 04718f0..4848833 100644 (file)
@@ -3374,6 +3374,9 @@ void spoil_random_artifact(cptr fname)
        char buf[1024];
 
 
+       /* Drop priv's */
+       safe_setuid_drop();
+
        /* Build the filename */
        path_build(buf, 1024, ANGBAND_DIR_USER, fname);
 
@@ -3435,6 +3438,9 @@ void spoil_random_artifact(cptr fname)
                return;
        }
 
+       /* Grab priv's */
+       safe_setuid_grab();
+
        /* Message */
        msg_print("Successfully created a list file.");
 }