void init_saved_floors(PlayerType *player_ptr, bool force)
{
auto fd = -1;
- for (int i = 0; i < MAX_SAVED_FLOORS; i++) {
- saved_floor_type *sf_ptr = &saved_floors[i];
- auto floor_savefile = get_saved_floor_name(i);
- safe_setuid_grab();
- fd = fd_make(floor_savefile);
- safe_setuid_drop();
- check_saved_tmp_files(fd, &force);
- safe_setuid_grab();
- (void)fd_kill(floor_savefile);
- safe_setuid_drop();
- sf_ptr->floor_id = 0;
+ if (!savefile.empty()) {
+ for (int i = 0; i < MAX_SAVED_FLOORS; i++) {
+ saved_floor_type *sf_ptr = &saved_floors[i];
+ auto floor_savefile = get_saved_floor_name(i);
- safe_setuid_grab(player_ptr);
++ safe_setuid_grab();
+ fd = fd_make(floor_savefile);
+ safe_setuid_drop();
+ check_saved_tmp_files(fd, &force);
- safe_setuid_grab(player_ptr);
++ safe_setuid_grab();
+ (void)fd_kill(floor_savefile);
+ safe_setuid_drop();
+ sf_ptr->floor_id = 0;
+ }
}
max_floor_id = 1;
argv0 = argv[0];
#ifdef SET_UID
-
/* Default permissions on files */
(void)umask(022);
-
#endif
- /* Get the file paths */
init_stuff();
-
+ auto &ids = UnixUserIds::get_instance();
#ifdef SET_UID
-
- /* Get the user id (?) */
- p_ptr->player_uid = getuid();
-
+ ids.set_user_id(getuid());
#ifdef VMS
- /* Mega-Hack -- Factor group id */
- p_ptr->player_uid += (getgid() * 1000);
+ ids.mod_user_id(getgid() * 1000);
#endif
- #ifdef SAFE_SETUID
-
- #ifdef _POSIX_SAVED_IDS
-
- /* Save some info for later */
- p_ptr->player_euid = geteuid();
- p_ptr->player_egid = getegid();
-
+ #if defined(SAFE_SETUID) && defined(_POSIX_SAVED_IDS)
+ ids.set_effective_user_id(geteuid());
+ ids.set_effective_group_id(getegid());
#endif
- #endif
-
- #endif
+ #endif /* SET_UID */
- /* Drop permissions */
safe_setuid_drop();
-
#ifdef SET_UID
-
- /* Acquire the "user name" as a default player name */
- user_name(p_ptr->name, p_ptr->player_uid);
-
+ user_name(p_ptr->name, ids.get_user_id());
#ifdef PRIVATE_USER_PATH
-
- create_user_dir();
+ /* Create a directory for the user's files; handled by init.c. */
+ create_needed_dirs();
-
#endif /* PRIVATE_USER_PATH */
-
#endif /* SET_UID */
- /* Process the command line arguments */
- bool browsing_movie = false;
- for (i = 1; args && (i < argc); i++) {
- /* Require proper options */
+ auto browsing_movie = false;
+ for (auto i = 1; args && (i < argc); i++) {
if (argv[i][0] != '-') {
display_usage(argv[0]);
continue;