Compare commits

..
Author SHA1 Message Date
measlesbagel f5b08ba3bb fix(bionic): pack GStreamer's debug plugin, so game videos play
winegstreamer puts a capssetter, from the debug plugin, at the front of
every video stream's conversion chain. Wine creates it by name at run
time, so check-needed.py, which follows linked libraries, could not
catch the missing plugin, and those videos played nothing on Bionic.

(cherry picked from commit 4327e4f916)
2026-11-28 15:34:31 -05:00
xlulx 4cc258ef1f fix(bionic): give each launch its own temporary file for the registry and drive rewrites
(cherry picked from commit 9738afa692)
2026-11-28 15:34:31 -05:00
xlulx 6b93742e4d fix(bionic): run games from a DroidDeck-Proton prefix that start through a launcher
Europa Universalis IV, moved from DroidDeck-Proton to DroidDeck-Bionic, never got past its launcher:

- The network adapter list (GetAdaptersAddresses) never answered with the layer's default if_nameindex code, so the
  Paradox Launcher waited forever. launch.sh sets WINE_NEW_NDIS=1 (the layer's getifaddrs code); a game's
  environment can still set 0.
- The game reported "Steam not detected": the prefix still named Proton's steam.exe (PID 0x20) as Steam's running
  client, and here that PID is the program Steam started, which quits after starting the game. launch.sh writes
  the PID this tool's own prefixes carry (0xfffe) before Wine starts.
- Its Workshop mod was missing: DroidDeck-Proton's s: drive names the guest path of the Steam library, which this
  Wine cannot follow. proton gives the prefix's guest drive links their Android paths for the launch; a session's
  start gives them their guest paths back.

(cherry picked from commit 1ca15d18f4)
2026-11-28 15:34:30 -05:00
The412Banner b9cab09dd4 feat(bionic): build DroidDeck-Bionic on the DroidDeck-Proton 11-14.1 Wine layer
The tool still packed the 12.8 layer (v16-unwind). The v18 layer is the build
of DroidDeck-Proton 11-14.1 Bannerlator ships: Valve Wine a47c73f52fd7, the
GE-Proton11-14 picks, and the ARM64EC code-map and unwind fixes 12.8 carried.
Same layout as 12.8 (three more files), so only the pin changes. Tools are
named DroidDeck-Bionic-14.1-rN; the app's version compare offers 14.1 over 12.8.
2026-11-28 15:34:04 -05:00
Kurt Himebauch 0859268591 test(semaphores): tell a child hung in qemu-user from a guest deadlock (#3375)
* test(semaphores): tell a child hung in qemu-user from a guest deadlock

* test(semaphores): calibrate qemu's guest base and end a stuck child on timeout
2026-11-28 12:02:37 -05:00
Kurt Himebauch 20b0358162 fix(session): kill a PRoot session's guests once proot is gone (#3376) 2026-11-28 10:45:29 -05:00
MaxsTechReview 65ebefc38f fix(desktop): Help Center, Software Sources and the driver manager open (#3371)
* fix(desktop): apps built on Qt's web engine start in the desktop and from AppImages

The desktop runs as root, and Qt WebEngine refuses to start as root with its
sandbox on, so Help Center and any other QtWebEngine app exited at once. Flatpaks
already had the sandbox off; the desktop and the AppImage runner now set it the
same way they turn off Firefox's sandboxes.

* fix(desktop): Software Sources and the driver manager open

software-properties-qt imports PyQt6.uic and UbuntuDrivers but does not depend
on the packages that ship them, so both tools died with an ImportError on the
installed-without-recommends desktop. The desktop package list now carries
pyqt6-dev-tools and ubuntu-drivers-common.
2026-11-28 10:24:50 -05:00
16 changed files with 334 additions and 100 deletions

No files matched your search

@@ -0,0 +1,54 @@
package com.droiddeck.launcher.session
import java.io.File
/** Finds the processes a session left running, also once proot is gone and they belong to init. */
object GuestLeftovers {
private const val MARKER = "DD_DEBUG_DIR="
fun find(rootfs: String, ended: File?, skip: Set<Int>): Set<Int> {
val marker = ended?.let { MARKER + it.path }
val parents = HashMap<Int, Int>()
val matched = HashSet<Int>()
File("/proc").listFiles { f -> f.name.all { it.isDigit() } }?.forEach { proc ->
val pid = proc.name.toIntOrNull() ?: return@forEach
parentOf(proc)?.let { parents[pid] = it }
if (pid in skip) return@forEach
val exe = runCatching { File(proc, "exe").canonicalPath }.getOrNull()
// proot runs a guest through its loader, which is then the process's executable
if (exe?.startsWith(rootfs) == true ||
marker != null && carries(runCatching { File(proc, "environ").readBytes() }.getOrNull(), marker)) {
matched.add(pid)
}
}
return withDescendants(matched, parents) - skip
}
internal fun carries(environ: ByteArray?, marker: String): Boolean {
if (environ == null) return false
val wanted = marker.toByteArray()
var start = 0
while (start < environ.size) {
var end = start
while (end < environ.size && environ[end] != 0.toByte()) end++
if (end - start == wanted.size && (0 until wanted.size).all { environ[start + it] == wanted[it] }) return true
start = end + 1
}
return false
}
internal fun withDescendants(roots: Set<Int>, parents: Map<Int, Int>): Set<Int> {
val out = HashSet(roots)
var grew = true
while (grew) {
grew = false
for ((pid, ppid) in parents) if (pid > 1 && ppid in out && out.add(pid)) grew = true
}
return out
}
private fun parentOf(proc: File): Int? {
val stat = runCatching { File(proc, "stat").readText() }.getOrNull() ?: return null
return stat.substringAfterLast(") ").split(' ').getOrNull(1)?.toIntOrNull()
}
}
@@ -1888,21 +1888,11 @@ class SessionService : Service() {
File(directory, STEAM_GAME_REQUEST + ".tmp").delete()
}
private fun killGuestLeftovers() {
val me = android.os.Process.myPid()
private fun killGuestLeftovers(ended: File?) {
val rootfs = try { File(filesDir, "linuxfs").canonicalPath } catch (e: Exception) { return } + "/"
val procs = File("/proc").listFiles { f -> f.name.all { it.isDigit() } } ?: return
val spared = OrphanReaper.spared()
var killed = 0
for (proc in procs) {
val pid = proc.name.toIntOrNull() ?: continue
if (pid == me || pid in spared) continue
val exe = try { File(proc, "exe").canonicalPath } catch (e: Exception) { continue }
if (!exe.startsWith(rootfs)) continue
android.os.Process.killProcess(pid)
killed++
}
if (killed > 0) Log.w(TAG, "killed $killed guest process(es) proot no longer tracked")
val leftovers = GuestLeftovers.find(rootfs, ended, OrphanReaper.spared() + android.os.Process.myPid())
leftovers.forEach { android.os.Process.killProcess(it) }
if (leftovers.isNotEmpty()) Log.w(TAG, "killed ${leftovers.size} guest process(es) proot no longer tracked")
}
private fun killStragglers() {
@@ -2388,7 +2378,7 @@ class SessionService : Service() {
com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession)
auxiliary.forEach { (pid, started) -> teardown(pid, started) }
if (prootPid > 1) teardown(prootPid)
killGuestLeftovers()
killGuestLeftovers(ended)
pruneSystemVulkanRuntime()
finishSessionStop(status, stoppedGen, collectEnded)
if (launcherEnded) importLauncherGames()
@@ -25,7 +25,6 @@ import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.outlined.Folder
import androidx.compose.material.icons.outlined.Image
import androidx.compose.material.icons.outlined.InsertDriveFile
import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material.icons.outlined.SdCard
import androidx.compose.material.icons.outlined.Smartphone
import androidx.compose.material.icons.outlined.Visibility
@@ -34,11 +33,9 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@@ -53,7 +50,6 @@ import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.contentDescription
@@ -63,10 +59,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import com.droiddeck.launcher.R
import com.droiddeck.launcher.files.AllFilesAccess
import com.droiddeck.launcher.files.StorageRoot
import com.droiddeck.launcher.files.StorageRoots
import com.droiddeck.launcher.stores.formatBytes
@@ -125,15 +118,7 @@ internal fun ExePickerDialog(
val back = { if (dir == null) close() else up() }
val first = remember(dir) { FocusRequester() }
LaunchedEffect(dir) { focusWithinFrames({ false }) { first } }
var resumed by remember { mutableIntStateOf(0) }
val lifecycle = LocalLifecycleOwner.current.lifecycle
DisposableEffect(lifecycle) {
val observer = LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_RESUME) resumed++ }
lifecycle.addObserver(observer)
onDispose { lifecycle.removeObserver(observer) }
}
val accessMissing = remember(resumed) { AllFilesAccess.missing() }
val listing = remember(dir, showHidden, resumed) { dir?.let { pickListing(it, kind, showHidden) } }
val listing = remember(dir, showHidden) { dir?.let { pickListing(it, kind, showHidden) } }
var locked by remember { mutableStateOf<Dp?>(null) }
AppDialog(
shown, close, "filePicker", wide = false, maxWidth = 520.dp, width = locked, fitContent = locked == null, back = back,
@@ -169,9 +154,6 @@ internal fun ExePickerDialog(
} else {
val shownListing = listing ?: PickListing(emptyList(), emptyList())
PickerRow(Icons.AutoMirrored.Outlined.ArrowBack, "..", null, focus = first, onClick = up)
if (accessMissing && volume != null) {
PickerRow(Icons.Outlined.Lock, stringResource(R.string.fm_drive_access_title, volume.label), null, accent = true) { AllFilesAccess.open(ctx) }
}
if (onAddAll != null && shownListing.folders.any { it.readable }) {
PickerRow(Icons.Filled.Add, stringResource(R.string.games_add_all), null, accent = true) { onAddAll(dir!!, showHidden); close() }
}
@@ -0,0 +1,35 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class GuestLeftoversTest {
private fun environ(vararg entries: String) = entries.joinToString("\u0000", postfix = "\u0000").toByteArray()
@Test
fun aProcessOfTheEndedSessionCarriesItsFolder() {
val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam"
assertTrue(GuestLeftovers.carries(environ("HOME=/home/deck", marker, "TERM=xterm"), marker))
assertTrue(GuestLeftovers.carries(environ(marker), marker))
}
@Test
fun anotherSessionsFolderOrALongerPathIsNotTheEndedSession() {
val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam"
assertFalse(GuestLeftovers.carries(environ("DD_DEBUG_DIR=/data/logs/2026-11-28-86-steam"), marker))
assertFalse(GuestLeftovers.carries(environ("$marker-2"), marker))
assertFalse(GuestLeftovers.carries(environ("X$marker"), marker))
assertFalse(GuestLeftovers.carries(null, marker))
assertFalse(GuestLeftovers.carries(ByteArray(0), marker))
}
@Test
fun whatAMatchedProcessStartedGoesWithIt() {
// 10 was proot's child and now belongs to init; 12 cleared its environment; 20 is unrelated
val parents = mapOf(10 to 1, 11 to 10, 12 to 11, 13 to 12, 20 to 1, 21 to 20)
assertEquals(setOf(10, 11, 12, 13), GuestLeftovers.withDescendants(setOf(10), parents))
assertEquals(emptySet<Int>(), GuestLeftovers.withDescendants(emptySet(), parents))
}
}
@@ -1,51 +0,0 @@
package com.droiddeck.launcher.ui
import android.os.Environment
import android.provider.Settings
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.droiddeck.launcher.R
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowEnvironment
import java.io.File
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34], qualifiers = "w1200dp-h752dp-land", application = android.app.Application::class)
class ExePickerAccessTest {
@get:Rule val compose = createRobolectricComposeRule()
private val ctx get() = RuntimeEnvironment.getApplication()
private val allowRow get() = ctx.getString(R.string.fm_drive_access_title, ctx.getString(R.string.games_internal))
private fun gameFolder(): File =
File(Environment.getExternalStorageDirectory(), "Rom/Game").apply {
mkdirs()
File(this, "game.exe").writeText("x")
}
private fun showPicker(start: File) {
compose.setContent { ExePickerDialog("Add", start = start, onPick = {}, onDismiss = {}) }
compose.waitForIdle()
}
@Test fun withoutAllFilesAccessThePickerOffersToOpenTheSetting() {
ShadowEnvironment.setIsExternalStorageManager(false)
showPicker(gameFolder())
compose.onNodeWithText(allowRow).performClick()
compose.waitForIdle()
assertEquals(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, shadowOf(ctx).nextStartedActivity?.action)
}
@Test fun withAllFilesAccessThePickerListsTheExeWithoutTheAccessRow() {
ShadowEnvironment.setIsExternalStorageManager(true)
showPicker(gameFolder())
compose.onNodeWithText("game.exe").assertExists()
compose.onNodeWithText(allowRow).assertDoesNotExist()
}
}
+5 -4
View File
@@ -35,10 +35,11 @@ GAMESCOPE_COMMIT=8f212644c46460549035971ab914421180f61a7c
GAMESCOPE_PATCHES="0117-wsi-cache-present-bypass-check.patch 0119-wsi-default-images-under-limiter.patch"
VULKAN_HEADERS_TAG=v1.4.341
# The bionic DroidDeck-Proton layer the pack is made for: linked against (libwayland-client) and checked against, not packed.
# Layer v16 (067c719d) plus the ARM64EC code-map fix for 39-bit hosts (d4c9ffa7, run 44291095238).
LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261118-v16-unwind/DroidDeck-Proton-11.0-12.8-arm64ec.wcp
LAYER_SHA256=3cc74b877bc8707d75aa2cc22e335373b6a6c0b6b1937c7b3c2cd98e55de2e89 # proton-wine d48e30a1 (a188791d + fecf7376 on d4c9ffa7)
LAYER_VERSION=12.8
# Layer v18: DroidDeck-Proton 11-14.1 (Valve Wine a47c73f52fd7, as GE-Proton11-14), the build Bannerlator ships; it
# carries the ARM64EC code-map and unwind fixes the 12.8 layer had (5ebfaa6f, 2515a989, e88fab40).
LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261124-v18/DroidDeck-proton-11.0-14.1-arm64ec.wcp
LAYER_SHA256=bf94176180e96584185835f9e80b168666f9fa752aa9583cfedb8fe493134ff6 # proton-wine 1a5735e7 (run 45926928349)
LAYER_VERSION=14.1
# Packed into the DroidDeck-Bionic tool next to the layer: FEX with Android-built unix libraries, and default
# DXVK / VKD3D-Proton (DroidDeck components can swap these in files/lib/wine/{dxvk,vkd3d-proton} later).
FEX_URL=https://github.com/The412Banner/Nightlies/releases/download/FEXCore-2611.1/FEXCore-2611.1-unix.wcp
+1
View File
@@ -1,6 +1,7 @@
# GStreamer plugins packed for winegstreamer (game video/audio), from the imagefs's lib/gstreamer-1.0 by name
# (libgst<name>.so): Proton's usual set as far as this imagefs has it (no vpx; videoconvert+videoscale are videoconvertscale).
coreelements
debug
app
audioconvert
audiorate
+18
View File
@@ -109,6 +109,9 @@ export NTSYNC_SHM=$COMPAT/ntsync-shm
# DroidDeck's Force SSBS (its glibc libssbs.so preload) is bionic Wine's own WINE_FORCE_SSBS
on "${DROIDDECK_FORCE_SSBS:-}" && export WINE_FORCE_SSBS=1
export HODLL=libwow64fex.dll WINEDEBUG=err+all,fixme-all
# The network adapter list (GetAdaptersAddresses) from the layer's getifaddrs code: its default if_nameindex code never
# answered here, and the Paradox Launcher (Europa Universalis IV) waited on it forever.
export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1}
export XENVIRONMENT=$TOOL/bionic/Xdefaults
# The adapter's Wayland swapchain gets its buffers back from gamescope later than DroidDeck-Proton's Turnip does;
# with gamescope's default three images the game waits for one about a fifth of the time at high frame rates.
@@ -306,6 +309,21 @@ if [ "$verb" != runinprefix ] && prefix_busy; then
fi
prefix_busy || rm -f "$NTSYNC_SHM".v*
# Steam's running client, as a game's steam_api checks it: Proton names its steam.exe (the prefix's first program,
# alive while the game runs), which this tool does not start. Here the first program is the one Steam started, so a
# launcher that starts the game and quits (EU4's dowser.exe) left a game that reported "Steam not detected". The
# PID is the one this tool's own prefixes carry.
steam_pid() {
R=$COMPAT/pfx/user.reg
[ -f "$R" ] || return 0
awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 }
on && /^"PID"=dword:/ && $0 != "\"PID\"=dword:0000fffe" { found = 1 } END { exit !found }' "$R" || return 0
awk '/^\[/ { on = index($0, "[Software\\\\Valve\\\\Steam\\\\ActiveProcess]") == 1 }
on && /^"PID"=dword:/ { print "\"PID\"=dword:0000fffe"; next } { print }' "$R" > "$R.dd-new.$$" && mv -f "$R.dd-new.$$" "$R" &&
echo "$(date +%H:%M:%S) Steam's process ID in the registry set to this tool's"
}
prefix_busy || steam_pid
# Links into a tool that is gone (an older DroidDeck-Bionic, a deleted DroidDeck-Proton) or to a file it no longer has.
# Wine's update cannot write over them, so drivers (network, controller) and other files stay missing. Drop them and
# clear both stamps: prepare_prefix relinks this tool's files and Wine's update puts its own back.
+16
View File
@@ -36,6 +36,21 @@ zpath() {
esac
}
# Drive links of the prefix in compatdata folder $1 that name guest paths (DroidDeck-Proton's s: for the Steam library)
# -> their Android paths, which this Wine follows. A game's mods on S: were missing otherwise. A session's start
# gives them their guest paths back (NativeGuest.relinkPrefixDrives); z: is launch.sh's.
android_drives() {
local d t a
for d in "$1"/pfx/dosdevices/[a-y]:; do
[ -L "$d" ] || continue
t=$(readlink "$d")
case "$t" in /*) ;; *) continue ;; esac
a=$(real "$t")
[ "$a" = "$t" ] && continue
ln -sfn "$a" "$d.dd-new.$$" && mv -fT "$d.dd-new.$$" "$d" && echo "drive ${d##*/} -> $a"
done
}
# Where a game launch's log goes in DroidDeck's session folder (Share logs takes that folder): the game's log folder
# when Detailed graphics logs made one (droiddeck-game-env), else a folder of its own; nothing for other verbs
session_logs() {
@@ -109,6 +124,7 @@ print(" ".join(sorted(n for n in names if re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*"
PY
)
export DROIDDECK_BIONIC_KEEP
[ -n "${STEAM_COMPAT_DATA_PATH:-}" ] && android_drives "$STEAM_COMPAT_DATA_PATH" >&2
exec /system/bin/sh "$tool/bionic/launch.sh" "$verb" "$compat" "$exe" ${args[@]+"${args[@]}"} ;;
getcompatpath)
p=$(real "${1:-}")
+1
View File
@@ -10,6 +10,7 @@ export SHELL=/bin/bash
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
export MOZ_SHM_NO_SEALS=1
export QTWEBENGINE_DISABLE_SANDBOX=1
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
export KWIN_USE_OVERLAYS=0
[ -e /etc/mpv/mpv.conf ] || { mkdir -p /etc/mpv && echo gpu-sw=yes >/etc/mpv/mpv.conf; } 2>/dev/null
@@ -12,6 +12,7 @@ fi
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
export MOZ_SHM_NO_SEALS=1
export QTWEBENGINE_DISABLE_SANDBOX=1
if [ -s /etc/ld.so.preload ]; then
preload=$(tr -s '\n' ':' < /etc/ld.so.preload)
export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1
+6 -1
View File
@@ -6,7 +6,7 @@ import unittest
from pathlib import Path
RUN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-appimage-run"
KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI")
KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI", "QTWEBENGINE_DISABLE_SANDBOX")
QUICK = ("usr/lib/libQt6Quick.so.6", "usr/lib/libvulkan.so.1", "usr/plugins/platforms/libqwayland-generic.so")
RUN_MODE = {"GAMESCOPE_WAYLAND_DISPLAY": "gamescope-0", "WAYLAND_DISPLAY": "gamescope-0", "DISPLAY": ":0",
"QT_QPA_PLATFORM": "xcb", "SDL_VIDEODRIVER": "x11", "XDG_SESSION_TYPE": "x11"}
@@ -128,6 +128,11 @@ class AppImageRunTest(unittest.TestCase):
self.assertEqual("wayland;xcb", env["QT_QPA_PLATFORM"])
def test_a_web_engine_app_starts_as_root_in_either_session(self):
for session in (RUN_MODE, DESKTOP):
env, _ = self.launch(session)
self.assertEqual("1", env["QTWEBENGINE_DISABLE_SANDBOX"])
def test_a_program_drops_the_sessions_sysmem_like_a_steam_game(self):
env, _ = self.launch(dict(RUN_MODE, TU_DEBUG="sysmem", DROIDDECK_GAME_TU_DEBUG=""))
self.assertEqual("unset", env["TU_DEBUG"])
+47
View File
@@ -144,6 +144,53 @@ class LaunchLog(unittest.TestCase):
self.assertIn('DXVK_LOG_PATH=${DXVK_LOG_PATH:-$COMPAT}', text)
class PrefixFromProton(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup)
self.compat = Path(self.tmp.name) / 'compatdata/236850'
self.drives = self.compat / 'pfx/dosdevices'
self.drives.mkdir(parents=True)
def test_guest_drive_links_get_android_paths(self):
for name, target in (('c:', '../drive_c'), ('s:', '/root/.local/share/Steam'), ('d:', '/mnt/sd/Steam'),
('e:', '/storage/emulated/0/Games'), ('z:', '/')):
os.symlink(target, self.drives / name)
out = proton_function('android_drives "$1"', str(self.compat))
links = {p.name: os.readlink(p) for p in self.drives.iterdir()}
self.assertEqual({'c:': '../drive_c', 's:': ANDROID + '/root/.local/share/Steam', 'd:': '/storage/1234-5678/Steam/Steam',
'e:': '/storage/emulated/0/Games', 'z:': '/'}, links)
self.assertEqual(2, len(out.splitlines()))
self.assertEqual('', proton_function('android_drives "$1"', str(self.compat)))
def test_a_prefix_without_drives_is_left_alone(self):
self.assertEqual('', proton_function('android_drives "$1"', str(Path(self.tmp.name) / 'compatdata/1')))
def steam_pid(self, reg):
text = LAUNCH.read_text()
function = text[text.index('steam_pid() {'):text.index('prefix_busy || steam_pid')]
(self.compat / 'pfx/user.reg').write_text(reg)
out = subprocess.run(['sh', '-c', function + 'steam_pid'], env=dict(os.environ, COMPAT=str(self.compat)),
capture_output=True, text=True, check=True).stdout
return out, (self.compat / 'pfx/user.reg').read_text()
def test_steams_process_id_is_this_tools(self):
reg = ('[Software\\\\Valve\\\\Steam\\\\ActiveProcess] 1795314478\n#time=1dd7a2916a0be94\n"PID"=dword:00000020\n'
'"SteamPath"="C:\\\\Program Files (x86)\\\\Steam"\n\n[Software\\\\Other] 1\n"PID"=dword:00000020\n')
out, after = self.steam_pid(reg)
self.assertIn('process ID', out)
self.assertEqual(reg.replace('"PID"=dword:00000020', '"PID"=dword:0000fffe', 1), after)
out, again = self.steam_pid(after)
self.assertEqual(('', after), (out, again))
def test_a_prefix_without_steams_key_is_unchanged(self):
reg = '[Software\\\\Wine] 1\n"PID"=dword:00000020\n'
self.assertEqual(('', reg), self.steam_pid(reg))
def test_the_network_list_uses_getifaddrs(self):
self.assertIn('export WINE_NEW_NDIS=${WINE_NEW_NDIS:-1}', LAUNCH.read_text())
class StorePaths(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
+36
View File
@@ -0,0 +1,36 @@
import os
from pathlib import Path
import subprocess
import unittest
TOOLS = Path(__file__).resolve().parents[1]
DESKTOP = (TOOLS / "linuxfs/desktop/droiddeck-desktop").read_text()
PACKAGES = (TOOLS / "ubuntu/packages-desktop.txt").read_text().split()
SANDBOXES = ("MOZ_DISABLE_CONTENT_SANDBOX", "MOZ_SHM_NO_SEALS", "QTWEBENGINE_DISABLE_SANDBOX")
class DesktopRootAppsTest(unittest.TestCase):
def desktop_environment(self):
head = DESKTOP[:DESKTOP.index("\nexport KWIN_COMPOSE=")]
env = {k: v for k, v in os.environ.items() if k not in SANDBOXES}
probe = "".join('echo %s=${%s-unset}\n' % (name, name) for name in SANDBOXES)
result = subprocess.run(["bash", "-c", head + "\nsh -c '" + probe + "'"], env=env,
capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
return dict(line.split("=", 1) for line in result.stdout.splitlines())
def test_web_engine_apps_start_as_root_like_firefox(self):
self.assertEqual({name: "1" for name in SANDBOXES}, self.desktop_environment())
def test_the_sandbox_switches_are_set_before_plasma(self):
self.assertLess(DESKTOP.index("export QTWEBENGINE_DISABLE_SANDBOX=1"),
DESKTOP.index("dbus-run-session -- startplasma-wayland"))
def test_software_sources_gets_the_modules_it_imports(self):
self.assertIn("software-properties-qt", PACKAGES)
for module in ("pyqt6-dev-tools", "ubuntu-drivers-common"):
self.assertIn(module, PACKAGES)
if __name__ == "__main__":
unittest.main()
+106 -10
View File
@@ -1,5 +1,6 @@
from pathlib import Path
import os
import signal
import subprocess
import tempfile
import unittest
@@ -54,12 +55,70 @@ FORKER = r"""
#include <fcntl.h>
#include <pthread.h>
#include <semaphore.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <unistd.h>
static const char *name;
static _Atomic int done;
static _Atomic int parked_word;
static _Atomic pid_t parked_tid;
// the host's futex call: 202 on x86-64, where qemu-user runs, 98 on aarch64
static int blocked_futex(const char *path, unsigned long *addr) {
unsigned long nr = 0;
FILE *f = fopen(path, "r");
int got = f && fscanf(f, "%lu %lx", &nr, addr) == 2;
if (f) fclose(f);
return got && (nr == 202 || nr == 98);
}
static void *park(void *arg) {
parked_tid = (pid_t)syscall(SYS_gettid);
while (!parked_word) syscall(SYS_futex, &parked_word, 0 /* FUTEX_WAIT */, 0, NULL, NULL, 0);
return arg;
}
// How far qemu-user moved the guest in the host's address space (its guest_base; 0 natively): a
// thread parked on a futex this program knows shows that futex's host address in its syscall file,
// which qemu-user passes through unlike /proc/self/maps.
static long guest_base(void) {
char path[96];
unsigned long addr = 0;
while (!parked_tid) usleep(1000);
snprintf(path, sizeof(path), "/proc/%d/task/%d/syscall", (int)getpid(), (int)parked_tid);
for (int i = 0; i < 5000; i++) {
if (blocked_futex(path, &addr) && addr) return (long)(addr - (unsigned long)&parked_word);
usleep(1000);
}
return -1;
}
// A child that hangs in qemu-user itself: a fork while another thread is inside the emulator's
// own locks (its mmap() handling) can leave the child waiting on a futex in qemu's memory, which no
// guest lock is. The child's blocking call shows the host's address; under qemu-user this
// program's /proc/self/maps lists the guest's mappings only, and a futex outside all of them, once
// moved back by the guest base, is the emulator's. Natively every futex is in the process's own
// mappings: never counted. Seen on x86 runners; there is no emulator on a device.
static int stuck_in_emulator(pid_t pid, long base) {
char path[64], line[512];
unsigned long addr = 0;
snprintf(path, sizeof(path), "/proc/%d/syscall", (int)pid);
if (base < 0 || !blocked_futex(path, &addr)) return 0;
addr -= (unsigned long)base;
FILE *f = fopen("/proc/self/maps", "r");
if (!f) return 0;
int guest = 0;
while (!guest && fgets(line, sizeof(line), f)) {
unsigned long start, end;
if (sscanf(line, "%lx-%lx", &start, &end) == 2 && addr >= start && addr < end) guest = 1;
}
fclose(f);
return !guest;
}
static void *churn(void *arg) {
while (!done) {
@@ -71,24 +130,40 @@ static void *churn(void *arg) {
int main(int argc, char **argv) {
name = argv[1];
pthread_t thread;
pthread_t parked, thread;
if (pthread_create(&parked, NULL, park, NULL) != 0) return 1;
long base = guest_base();
printf("base\t%ld\n", base);
if (pthread_create(&thread, NULL, churn, NULL) != 0) return 1;
int finished = 0;
int finished = 0, emulator = 0;
for (int i = 0; i < 200; i++) {
pid_t pid = fork();
if (pid < 0) break;
if (pid == 0) {
alarm(10);
sem_t *sem = sem_open(name, O_CREAT, 0600, 0);
_exit(sem == SEM_FAILED || sem_close(sem) != 0);
}
int status;
if (waitpid(pid, &status, 0) == pid && WIFEXITED(status) && WEXITSTATUS(status) == 0) finished++;
int status = 0, stalled = 0;
pid_t r;
for (int waited = 0; (r = waitpid(pid, &status, WNOHANG)) == 0; waited++) {
if (waited == 1000) { // 10 s
stalled = stuck_in_emulator(pid, base);
kill(pid, SIGKILL);
}
usleep(10000);
}
if (r != pid) continue;
if (stalled) emulator++;
else if (WIFEXITED(status) && WEXITSTATUS(status) == 0) finished++;
}
done = 1;
pthread_join(thread, NULL);
parked_word = 1;
syscall(SYS_futex, &parked_word, 1 /* FUTEX_WAKE */, 1, NULL, NULL, 0);
pthread_join(parked, NULL);
sem_unlink(name);
printf("finished\t%d\n", finished);
printf("emulator\t%d\n", emulator);
return 0;
}
"""
@@ -116,7 +191,7 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase):
def tearDownClass(cls):
cls.tmp.cleanup()
def run_hooked(self, program, *args):
def run_hooked(self, program, *args, timeout=120):
hook_env = {"DDNATV_ROOT": str(self.shm.parent.parent), "LD_PRELOAD": str(self.hook)}
env = {k: v for k, v in os.environ.items() if k != "LD_PRELOAD"}
if self.prefix:
@@ -124,9 +199,17 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase):
else:
cmd = []
env.update(hook_env)
out = subprocess.run(cmd + [str(program), *args], env=env, capture_output=True, text=True, timeout=120)
self.assertEqual(out.returncode, 0, out.stderr)
return dict(line.split("\t") for line in out.stdout.splitlines())
# its own process group, so a timeout also ends a child still blocked once the program is gone
proc = subprocess.Popen(cmd + [str(program), *args], env=env, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True, start_new_session=True)
try:
stdout, stderr = proc.communicate(timeout=timeout)
except subprocess.TimeoutExpired:
os.killpg(proc.pid, signal.SIGKILL)
proc.communicate()
raise
self.assertEqual(proc.returncode, 0, stderr)
return dict(line.split("\t") for line in stdout.splitlines())
def test_a_named_semaphore_lives_in_the_rootfs_and_is_shared_between_processes(self):
name = f"/ddsem-{os.getpid()}"
@@ -139,7 +222,20 @@ class NativeHookNamedSemaphoresTest(unittest.TestCase):
source.write_text(FORKER)
forker = self.probe.with_name("forker")
subprocess.run([self.cc, "-O1", "-pthread", "-o", str(forker), str(source)], check=True)
self.assertEqual({"finished": "200"}, self.run_hooked(forker, f"/ddsem-fork-{os.getpid()}"))
name = f"/ddsem-fork-{os.getpid()}"
# left by a run that did not get to sem_unlink(), it would fail the other tests' empty /dev/shm
self.addCleanup(lambda: (self.shm / f"sem.{name[1:]}").unlink(missing_ok=True))
# 200 forks under a loaded qemu-user, and 10 s for each child that hangs in the emulator
result = self.run_hooked(forker, name, timeout=300)
# every child opened one, but for one now and then that hung in qemu-user itself (a fork during
# the emulator's own locking), which a native run never has
if self.prefix:
self.assertNotEqual("-1", result.get("base"), result)
else:
self.assertEqual("0", result.get("base"), result)
emulator = int(result.get("emulator", "0"))
self.assertEqual(200, int(result.get("finished", "0")) + emulator, result)
self.assertLessEqual(emulator, 0 if not self.prefix else 3, result)
def test_a_created_semaphore_keeps_its_name_and_mode(self):
name = f"ddsem-kept-{os.getpid()}"
+2
View File
@@ -215,6 +215,7 @@ power-profiles-daemon
powerdevil
ppa-purge
print-manager
pyqt6-dev-tools
python3-dbus
python3-launchpadlib
python3-setuptools
@@ -241,6 +242,7 @@ software-properties-qt
squashfs-tools
synaptic
systemsettings
ubuntu-drivers-common
udisks2
unrar-free
upower