From d38fd373f0caf6574458abc574640f2d961d09d9 Mon Sep 17 00:00:00 2001 From: MaxsTechReview Date: Wed, 25 Nov 2026 05:48:37 -0500 Subject: [PATCH] fix(runtime): programs can open ProgramData folders a stale Windows owner locked (#3194) * Unlock ProgramData entries a stale Windows owner locked Wine builds the user SID from /etc/machine-id and the uid it runs as. When either changes, descriptors stored in user.wine.sd keep the old owner, and the next DACL change maps to mode 000 because no ACE matches the token. Wine then cannot open the entry, so programs such as Battle.net cannot repair their own folders. Before each launch, clear stale local user owners under ProgramData and give owner access back to entries they locked. * Heal a locked ProgramData itself and keep read-only folders * Serialise the ProgramData heal per prefix * Launch even when the ProgramData owner check fails * Read the machine ID as bytes the way Wine does * Parse a signed machine ID the way Wine does --- .../overlay/usr/local/bin/droiddeck-game-env | 132 +++++++++++++++ tools/tests/test_game_environment.py | 158 ++++++++++++++++++ 2 files changed, 290 insertions(+) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index cd0b393551..c6ba899633 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -1,4 +1,5 @@ #!/usr/bin/python3 +import fcntl import hashlib import json import os @@ -6,6 +7,8 @@ import platform import re import runpy import signal +import stat +import struct import subprocess import sys import tempfile @@ -1046,6 +1049,9 @@ WINE_DLL_DIRS = ("/lib/wine/i386-windows", "/lib/wine/x86_64-windows", "/lib/win FOREIGN_SUFFIX = ".foreign-arch" +WINE_SD = "user.wine.sd" +SHARED_DATA = "pfx/drive_c/ProgramData" +MACHINE_ID = "/etc/machine-id" PE = runpy.run_path(str(Path(__file__).resolve().parent / "droiddeck-wine-pe")) pe_machine = PE["pe_machine"] @@ -1144,6 +1150,124 @@ def repair_foreign_system_dlls(prefix, proton, env=None): return repaired +def wine_user_sid(): + try: + with open(MACHINE_ID, "rb") as handle: + text = handle.read(16) + except OSError: + return (21, 0, 0, 0, 1000) + if len(text) != 16: + return (21, 0, 0, 0, 1000) + sign, digits = re.match(rb"\s*([+-]?)(?:0[xX])?([0-9a-fA-F]*)", text).groups() + machine = int(digits, 16) if digits else 0 + if sign == b"-": + machine = -machine % (1 << 64) + return (21, machine >> 32, machine & 0xffffffff, os.getuid(), 1000) + + +def wine_sd_owner(path): + try: + data = os.getxattr(path, WINE_SD, follow_symlinks=False) + except OSError: + return None + if len(data) < 22: + return None + sid = data[22:22 + struct.unpack_from("