if (err1 > 0) return err1;
- /* Drop priv's */
- safe_setuid_drop();
-
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
/* Process the user pref file */
err2 = process_pref_file_aux(buf, FALSE);
- /* Grab priv's */
- safe_setuid_grab();
-
/* User file does not exist, but read system pref file */
if (err2 < 0 && !err1)
FILE *fff = NULL;
char buf[1024];
- /* Drop priv's */
- safe_setuid_drop();
-
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
/* Close it */
my_fclose(fff);
- /* Grab priv's */
- safe_setuid_grab();
/* Message */
#ifdef JP
/* Close it */
my_fclose(fff);
- /* Drop priv's */
- safe_setuid_drop();
-
/* Build the filename */
path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
my_fclose(fff);
my_fclose(ffp);
- /* Grab priv's */
- safe_setuid_grab();
-
/* Hack -- Re-Open the file */
fff = my_fopen(path, "r");
}
/* File type is "TEXT" */
FILE_TYPE(FILE_TYPE_TEXT);
+ /* Grab permissions */
+ safe_setuid_grab();
+
/* Try to write a new "Bones File" */
fp = my_fopen(str, "w");
+ /* Drop permissions */
+ safe_setuid_drop();
+
/* Not allowed to write it? Weird. */
if (!fp) return;
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
+ /* Grab permissions */
+ safe_setuid_grab();
+
/* Open the high score file, for reading/writing */
highscore_fd = fd_open(buf, O_RDWR);
+ /* Drop permissions */
+ safe_setuid_drop();
/* Handle death */
if (p_ptr->is_dead)
errr err = 0;
- /* Drop priv's */
- safe_setuid_drop();
-
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
err = process_pref_file_aux(buf, TRUE);
- /* Grab priv's */
- safe_setuid_grab();
-
/* Result */
return (err);
}
{
int fd;
char buf[1024];
+ errr err;
#ifdef JP
path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
#else
path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
#endif
+
+ /* Grab permissions */
+ safe_setuid_grab();
+
fd = fd_open(buf, O_RDWR);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
if (fd < 0)
{
/* File type is "DATA" */
fd = fd_make(buf, 0644);
}
- if (fd_lock(fd, F_WRLCK)) return 1;
+ /* Grab permissions */
+ safe_setuid_grab();
+
+ err = fd_lock(fd, F_WRLCK);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ if (err) return 1;
counts_seek(fd, where, TRUE);
fd_write(fd, (char*)(&count), sizeof(u32b));
- if (fd_lock(fd, F_UNLCK)) return 1;
+ /* Grab permissions */
+ safe_setuid_grab();
+
+ err = fd_lock(fd, F_UNLCK);
+
+ /* Drop permissions */
+ safe_setuid_drop();
+
+ if (err) return 1;
(void)fd_close(fd);