fix: lock config directory so Steam cannot overwrite launch options

Steam writes localconfig.vdf via atomic rename (write temp + rename over
original). chmod 444 on the file is bypassed by the rename. chmod 555 on
the directory blocks rename-into, preserving the launch option across
Steam restarts.

Also unlocks the directory at the start of step 6 so re-running the
script can update the launch option.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D8ckUJQtj1pH8jtAddBDZs
This commit is contained in:
Claude
2026-06-22 18:08:57 +00:00
parent 0c56837505
commit 77e40d4955
+8
View File
@@ -246,6 +246,9 @@ else
if [ ! -f "$CFG_FILE" ]; then
echo "WARNING: localconfig.vdf not found. Launch Steam first, then re-run."
else
CFG_DIR=$(dirname "$CFG_FILE")
# Remove directory lock before writing (in case script was run before)
chmod u+w "$CFG_DIR" 2>/dev/null || true
LAUNCH_OPT="$WRAPPER_PATH %command%"
python3 - "$CFG_FILE" "$LAUNCH_OPT" << 'PYEOF'
import sys, re
@@ -262,6 +265,11 @@ with open(path, 'w') as f:
f.write(new)
print(" LaunchOptions set.")
PYEOF
# Lock the directory so Steam's atomic rename cannot overwrite localconfig.vdf.
# Steam writes via rename(tmpfile, destination); write permission on the
# directory is required for rename-into. This preserves the launch option.
chmod 555 "$CFG_DIR"
echo " Config directory locked to prevent Steam overwrite"
fi
fi