Headless server changing save file permissions on stop

This subforum contains all the issues which we already resolved.
Post Reply
MakCuber
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Mar 01, 2016 5:18 am
Contact:

Headless server changing save file permissions on stop

Post by MakCuber »

Hello, first bug post, sorry if duplicate, didn't see anything addressing this issue when I searched for it. I think I found a really obscure error.

System Info
Factorio server version: 0.15.6
OS: ArchLinux 4.10.13-1-ARCH

Description
I seem to have stumbled on a bug where after the Headless server quits it resets the file permissions, owner, and group of the save file. It sets the files permissions to -rw-r--r--, it sets the file owner to be the user who started the server, and it sets the group to be the primary group of the user who started the server.

Tests
- Ran the server manually without my management script and the issue persisted, so it doesn't seem to be an issue with my code
- These permissions appear to also be set for newly generated save files

I realize this will not be an issue for 99% of players as they most likely will only ever run the headless server under one user, but the way I have my server management script setup atm, servers can be run by any user in a group called "factorio". I could change it so that servers are always run under a user name "factorio" regardless of what user run the management script, but I still think the file permissions shouldn't be modified every time you run the server.

Also this issue may have prevented the server from saving the last time I played, as there was about 2 hours worth of changes missing from the map when I restarted the server, despite numerous manual save commands being sent prior to shutdown (that'll teach me to make local backups, that's for sure). Its possible that the issue I've described has nothing to do with the missing map updates, since as far as I recall I ran the server as the same user so it should have been able to write to the save file without issue. However it does seem like quite the coincidence that I notice this permission bug and the missing map updates within the same day. Its also worth noting here that the group the save file is changed to is root, so its possible that the server cant save properly due to this, but it shouldn't since its also setting the permissions to r/w for the user Im running it as and Im not using sudo when I run it. I'll keep looking into the missing map updates issue separately since it may not related to the permissions issues, but my guess is that it is related somehow.

Thanks for reading, I love this game and the devs are f*cking code ninjas!! (5 patches in the first week after a big release, 2 on the same day, and on weekends?!)

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Headless server changing save file permissions on stop

Post by posila »

Hi, the server saves the game on stop. Saving is always done to a new file in order to not destroy old file in case of error or crash during saving. Then old file is deleted and new file is renamed.

MakCuber
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Mar 01, 2016 5:18 am
Contact:

Re: Headless server changing save file permissions on stop

Post by MakCuber »

Okay ya that's what I figured happened, thanks for the quick reply, but why are the permissions of the old file not being read and then applied to the new file? I mean as it works currently wouldn't it technically be possible for a user to basically take over another users save file just by loading and re-saving it to change the ownership? Doing so would delete the old file and recreate it with permissions that potentially prevent the originally user from accessing it, or at least would allow the new user to now change the permissions so no other user can read the save file since they are now the file's owner. Again this isn't a huge issues but I just don't get why the permissions are not maintained when the game saves the map. I've started overhauling my management script so that it won't be affected by this issue, but I still think it should be changed so that the permission stay the same.

Oxyd
Former Staff
Former Staff
Posts: 1428
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: Headless server changing save file permissions on stop

Post by Oxyd »

Okay, I changed it so that Factorio will remember the original permissions and owner/group and then try to apply them to the new file.

Post Reply

Return to “Resolved Problems and Bugs”