[0.18.18] Headless server doesn't follow symbolic links when validating the save location is a directory

Things that has been reported already before.
Post Reply
exicx
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Apr 09, 2020 6:20 pm
Contact:

[0.18.18] Headless server doesn't follow symbolic links when validating the save location is a directory

Post by exicx »

Hello,

I'm trying to create a new save file using the linux headless factorio server. I've setup a symbolic link from /opt/factorio/saves to /factorio/saves. However when I try to create a new save file in /opt/factorio/saves/test.zip it fails because the game checks that /opt/factorio/saves is a directory. How this should work is it should follow the symbolic link to /factorio/saves, and then perform the directory check, where it'll then create the new save file. Loading from a symbolic link location works fine, it's just when creating that the problem exists.

Code: Select all

Creating a new save file
   0.000 2020-04-09 17:50:25; Factorio 0.18.18 (build 50828, linux64, headless)
   0.000 Operating system: Linux
   0.000 Program arguments: "/opt/factorio/bin/x64/factorio" "--create" "/opt/factorio/saves/test.zip" 
   0.000 Read data path: /opt/factorio/data
   0.000 Write data path: /opt/factorio [192004/409560MB]
   0.000 Binaries path: /opt/factorio/bin
   0.010 System info: [CPU: AMD Ryzen 7 2700 Eight-Core Processor, 16 cores, RAM: 15930 MB]
   0.011 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=<unset> DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> __GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
   0.011 Running in headless mode
   0.016 Loading mod core 0.0.0 (data.lua)
   0.071 Loading mod base 0.18.18 (data.lua)
   0.309 Loading mod base 0.18.18 (data-updates.lua)
   0.433 Checksum for core: 1106864506
   0.433 Checksum of base: 332375697
   0.603 Prototype list checksum: 586383188
   0.639 Info PlayerData.cpp:70: Local player-data.json unavailable
   0.639 Info PlayerData.cpp:75: Cloud player-data.json unavailable
   0.645 Factorio initialised
   0.646 Info Main.cpp:709: Creating new map /opt/factorio/saves/test.zip
   1.463 Loading level.dat: 1068014 bytes.
   1.463 Info Scenario.cpp:187: Map version 0.18.18-1
   1.482 Checksum for script /opt/factorio/temp/currently-playing/control.lua: 3441332399
   1.526 Goodbye
   0.000 Error Util.cpp:83: filesystem error: create_directories "/opt/factorio/saves" failed: Not a directory [/opt/factorio/saves]

Strangely, the game only checks if the final location in the path is a directory. So, if /opt/factorio/saves is a symbolic link to /factorio/saves. Then saving to /opt/factorio/saves/save1/test.zip works just fine (which actually becomes /factorio/saves/save1/test.zip).

Thanks,
exicx
Last edited by exicx on Sun Apr 12, 2020 1:51 am, edited 2 times in total.

exicx
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Apr 09, 2020 6:20 pm
Contact:

Re: [0.18.18] Headless server doesn't follow symbolic links when creating a new save file

Post by exicx »

This also applies to the latest stable version too (0.17.79), so it's not a new bug :)

Nemirtingas
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Apr 10, 2020 8:39 am
Contact:

Re: [0.18.18] Headless server doesn't follow symbolic links when validating the save location is a directory

Post by Nemirtingas »

Hi,

I confirm that and I can also add my case when this happened.
On my linux server I have this layout:

Code: Select all

drwxr-xr-x 1 factorio factorio  378 Apr  6 22:16 factorio-0.18.15
drwxr-xr-x 1 factorio factorio  286 Apr  9 12:31 factorio-0.18.17
drwxr-xr-x 1 factorio factorio  292 Apr 10 10:38 factorio-0.18.18
drwxr-xr-x 1 factorio factorio   34 Apr  9 12:31 factorio-data
lrwxrwxrwx 1 factorio factorio   16 Apr  9 12:34 factorio-server -> factorio-0.18.18
In 'factorio-server' I have this:

Code: Select all

drwxr-xr-x 1 factorio factorio  292 Apr 10 10:38 ./
drwxr-xr-x 1 factorio factorio  266 Apr  9 13:06 ../
-rw-r--r-- 1 factorio factorio 1.5K Apr  9 12:43 achievements.dat
drwxrwxr-x 1 factorio factorio    6 Apr  9 12:29 bin/
drwxr-xr-x 1 factorio factorio   20 Apr  9 12:43 config/
-rw-r--r-- 1 factorio factorio  998 Jan 16  2018 config-path.cfg
drwxr-xr-x 1 factorio factorio  328 Apr  9 12:40 data/
-rw-r--r-- 1 factorio factorio  34K Apr 10 10:38 factorio-current.log
-rw-r--r-- 1 factorio factorio  35K Apr 10 10:35 factorio-previous.log
-rw-r----- 1 factorio factorio    0 Apr 10 10:32 .lock
drwxrwxr-x 1 factorio factorio  202 Apr 10 10:37 mods/
-rw-r--r-- 1 factorio factorio 1.8K Apr 10 10:38 player-data.json
lrwxrwxrwx 1 factorio factorio   33 Apr  9 12:37 saves -> /opt/factorio/factorio-data/saves/
-rw-r--r-- 1 factorio factorio  120 Apr  9 12:44 server-id.json
drwxr-xr-x 1 factorio factorio   34 Apr 10 10:38 temp/
When I start the server, it works fine, when I play it works fine, autosave working, but when all players left, it can't save the real save (not the _autosave) and exits the game with this errors:

Code: Select all

Apr 10 02:36:11 serverprive factorio-Nemir's Server[4067]: 49940.979 Info ServerSynchronizer.cpp:618: nextHeartbeatSequenceNumber(1619729) removing peer(1).
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49941.991 Info ServerMultiplayerManager.cpp:1187: Auto saving map as /opt/factorio/factorio-server/saves/Nemir's Server.zip
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49941.992 Info AppManager.cpp:404: Saving game as /opt/factorio/factorio-server/saves/Nemir's Server.zip
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.034 Info AsyncScenarioSaver.cpp:144: Saving process PID: 667
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.068 Error AsyncScenarioSaver.cpp:179: Saving failed: filesystem error: create_directories "/opt/factorio/factorio-server/saves" failed: Not a directory [/opt/factorio/factorio-server/saves]
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.085 Error AsyncScenarioSaver.cpp:179: Saving failed: filesystem error: create_directories "/opt/factorio/factorio-server/saves" failed: Not a directory [/opt/factorio/factorio-server/saves]
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.102 Error AsyncScenarioSaver.cpp:179: Saving failed: filesystem error: create_directories "/opt/factorio/factorio-server/saves" failed: Not a directory [/opt/factorio/factorio-server/saves]
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.108 Info ChildProcessAgent.cpp:60: Child 667 exited with return value 1
Apr 10 02:36:12 serverprive factorio-Nemir's Server[4067]: 49942.113 Error Util.cpp:83: Attempting to create notice box in headless mode. Message: 'filesystem error: create_directories "/opt/factorio/factorio-server/saves" failed: Not a directory [/opt/factorio/factorio-server/saves]'
Apr 10 02:36:13 serverprive factorio-Nemir's Server[4067]: 49943.172 Info ServerMultiplayerManager.cpp:112: Disconnecting multiplayer connection.
Apr 10 02:36:13 serverprive factorio-Nemir's Server[4067]: 49943.172 Info ServerMultiplayerManager.cpp:771: updateTick(4294967295) changing state from(InGame) to(DisconnectingScheduled)
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.342 Info ServerMultiplayerManager.cpp:136: Quitting multiplayer connection.
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.342 Info ServerMultiplayerManager.cpp:771: updateTick(4294967295) changing state from(DisconnectingScheduled) to(Closed)
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.346 Info HttpSharedState.cpp:54: Downloading https://multiplayer.factorio.com/remove-game/7183608
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.443 Info UDPSocket.cpp:218: Closing socket
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.443 Info UDPSocket.cpp:248: Socket closed
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.443 Info UDPSocket.cpp:218: Closing socket
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.595 Info UDPSocket.cpp:218: Closing socket
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.596 Info UDPSocket.cpp:248: Socket closed
Apr 10 02:36:14 serverprive factorio-Nemir's Server[4067]: 49943.598 Goodbye
Apr 10 02:36:14 serverprive systemd[1]: factorio@Nemir\x27s\x20Server.service: Main process exited, code=exited, status=1/FAILURE
Apr 10 02:36:14 serverprive systemd[1]: factorio@Nemir\x27s\x20Server.service: Failed with result 'exit-code'.
I'm glad there was an autosave x), I would have lost dozens of playtime :'(.

dyce
Burner Inserter
Burner Inserter
Posts: 16
Joined: Mon Jul 08, 2019 9:13 am
Contact:

Re: [0.18.18] Headless server doesn't follow symbolic links when validating the save location is a directory

Post by dyce »

This may (or may not) be related 68499

exicx
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu Apr 09, 2020 6:20 pm
Contact:

Re: [0.18.18] Headless server doesn't follow symbolic links when validating the save location is a directory

Post by exicx »

dyce wrote:
Mon Apr 20, 2020 7:46 am
This may (or may not) be related 68499
It is, indeed! Thanks.

I question the value of this attitude towards symlinks. These have to be created explicitly by the user: this is what I want to be doing. The game should not get in the way of my system administration. As a professional sysadmin, there isn't really any software out there that actively prevents writing to a symlink'd dir.

To be honest this is a minor issue, and I've worked around it already in my docker entry scripts. It's quite the head scratcher because I'm really not following the logic as to why the would have intentionally put a change like this in.

Post Reply

Return to “Duplicates”