Skip to content

Commit be38d0f

Browse files
committed
umu_util: ensure umu_version.json is writable after copied
- Related to #106
1 parent 002fd78 commit be38d0f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

umu/umu_util.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from sys import version
22
from tarfile import open as tar_open, TarInfo
3-
from os import environ
3+
from os import environ, access, W_OK
44
from umu_consts import CONFIG, UMU_LOCAL
55
from typing import Any
66
from collections.abc import Callable
@@ -16,6 +16,7 @@
1616
from concurrent.futures import ThreadPoolExecutor, Future
1717
from hashlib import sha256
1818
from subprocess import run
19+
from stat import S_IWUSR
1920

2021
SSL_DEFAULT_CONTEXT: SSLContext = create_default_context()
2122

@@ -172,13 +173,20 @@ def _install_umu(root: Path, local: Path, json: dict[str, Any]) -> None:
172173
defined at build time, with the exception of umu-launcher which will be
173174
installed in $PREFIX/share/steam/compatibilitytools.d
174175
"""
176+
json_local: Path = local.joinpath(CONFIG)
177+
175178
log.debug("New install detected")
176179
log.console("Setting up Unified Launcher for Windows Games on Linux ...")
177180
local.mkdir(parents=True, exist_ok=True)
178181

179182
# Config
180183
log.console(f"Copied {CONFIG} -> {local}")
181-
copy(root.joinpath(CONFIG), local.joinpath(CONFIG))
184+
copy(root.joinpath(CONFIG), json_local)
185+
186+
# Ensure the config file is writable for the owner after copied
187+
# See https://github.com/Open-Wine-Components/umu-launcher/issues/106
188+
if not access(local.joinpath(CONFIG), W_OK):
189+
json_local.chmod(json_local.stat().st_mode | S_IWUSR)
182190

183191
# Runtime platform
184192
setup_runtime(json)

0 commit comments

Comments
 (0)