From 77e40d4955753a202f3e48fd9c20a1ea92eb21b7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 18:08:57 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01D8ckUJQtj1pH8jtAddBDZs --- scripts/setup-swbf2-linux.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/setup-swbf2-linux.sh b/scripts/setup-swbf2-linux.sh index f52aa12..101bcf5 100755 --- a/scripts/setup-swbf2-linux.sh +++ b/scripts/setup-swbf2-linux.sh @@ -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