diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ce91b27..746f734 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -18,6 +18,13 @@ if [ "$(id -u)" = "0" ]; then chown -R "$puid:$pgid" "$data_dir" chown "$puid:$pgid" "$media_dir" + # setpriv keeps root's HOME (/root), which the runtime user cannot write: Chromium's crash + # reporter then aborts at startup ("chrome_crashpad_handler: --database is required") and + # tools lose their caches. Give the runtime user a home of its own. + runtime_home="/tmp/easyx-home" + install -d -m 0700 -o "$puid" -g "$pgid" "$runtime_home" + export HOME="$runtime_home" + umask 002 exec setpriv --reuid="$puid" --regid="$pgid" --clear-groups /usr/bin/tini -- "$@" fi diff --git a/scripts/easyx-browser-fetch.py b/scripts/easyx-browser-fetch.py index 6fb3702..6e93c82 100644 --- a/scripts/easyx-browser-fetch.py +++ b/scripts/easyx-browser-fetch.py @@ -16,6 +16,14 @@ from websockets.asyncio.client import connect +# Chromium's crash reporter needs a writable home: without one it exits at once +# ("chrome_crashpad_handler: --database is required"), for example when the container +# drops root privileges but keeps HOME=/root. +if not os.access(os.environ.get("HOME") or "/nonexistent", os.W_OK): + os.environ["HOME"] = os.path.join(tempfile.gettempdir(), f"easyx-home-{os.getuid()}") + os.makedirs(os.environ["HOME"], mode=0o700, exist_ok=True) + + MEDIA_URL_RE = re.compile( r"https?://[^\s'\"<>\\]+?(?:\.m3u8|\.mpd)(?:\?[^\s'\"<>\\]*)?", re.IGNORECASE,