diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 08b966e98b..900823e0f4 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -191,9 +191,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var gamescopeRealtime by mutableStateOf(false) private var paceCores by mutableStateOf(true) private var gpuClockPin by mutableStateOf(false) - private var prootNoSeccomp by mutableStateOf(false) - private var prootFastPath by mutableStateOf(true) - private var nativeUserland by mutableStateOf(true) private var desktopAsUser by mutableStateOf(false) private var cursorComposite by mutableStateOf(true) private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME) @@ -3125,7 +3122,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet fsyncFirst = fsyncFirst, gamescopeRealtime = gamescopeRealtime, gpuClockPin = gpuClockPin, - prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, desktopAsUser = desktopAsUser, cursorComposite = cursorComposite, + nativeDesktopAvailable = com.droiddeck.launcher.runtime.NativeGuest.nextSession(this), desktopAsUser = desktopAsUser, cursorComposite = cursorComposite, guestHostname = guestHostname, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on }, @@ -3139,9 +3136,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on }, onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on }, onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on }, - onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, - onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on }, - onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on }, onDesktopAsUser = { on -> SessionPrefs.setDesktopAsUser(this, on); desktopAsUser = on }, onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on }, onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) }, @@ -3464,9 +3458,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet gamescopeRealtime = SessionPrefs.gamescopeRealtime(this) paceCores = SessionPrefs.paceCores(this) gpuClockPin = SessionPrefs.gpuClockPin(this) - prootNoSeccomp = SessionPrefs.prootNoSeccomp(this) - prootFastPath = SessionPrefs.prootFastPath(this) - nativeUserland = SessionPrefs.nativeUserland(this) desktopAsUser = SessionPrefs.desktopAsUser(this) cursorComposite = SessionPrefs.cursorComposite(this) guestHostname = SessionPrefs.guestHostname(this) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 371d200f47..3b5166bf5a 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -3862,7 +3862,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde presentationFaultHint()?.let { return it } if (log == null || !log.isFile) return null return try { - var enosys = 0 var fexMissing = false val size = log.length() val text = java.io.RandomAccessFile(log, "r").use { f -> @@ -3873,7 +3872,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde String(bytes, Charsets.ISO_8859_1) } text.lineSequence().forEach { line -> - if (line.contains("Function not implemented")) enosys++ if (line.contains(FEX_MISSING)) fexMissing = true } val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence()) @@ -3895,9 +3893,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else if (fexMissing) { val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program) EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true) - } else if (enosys >= 8) { - EndHint(resources.getQuantityString(R.plurals.session_hint_enosys, enosys, enosys, - getString(R.string.perf_title), getString(R.string.perf_seccomp), getString(R.string.perf_xalia))) } else null } catch (e: Exception) { null diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt index 87188e34d7..22c30a994e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt @@ -571,7 +571,6 @@ object AgentHost { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt index 613cbe2c39..0d2fffc73e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt @@ -14,8 +14,6 @@ object AgentNative { fun run(context: Context, request: JSONObject, timeoutMs: Long): JSONObject { val root = LinuxRuntime.rootDir(context) com.droiddeck.launcher.session.SessionFiles.stage(context, root) - // with the setting off, staging leaves the rootfs as proot wants it - if (!com.droiddeck.launcher.session.SessionPrefs.nativeUserland(context)) NativeGuest.prepare(context, root) if (!NativeGuest.available(root)) throw AgentException("NATIVE_UNAVAILABLE", "The rootfs has no native hook or glibc loader yet; start a session once") val argvJson = request.optJSONArray("argv") ?: throw AgentException("INVALID_REQUEST", "argv is required") val argv = (0 until argvJson.length()).map { argvJson.getString(it) } diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 4beeec8d45..46b74fbafa 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -291,9 +291,12 @@ object DeviceReport { k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up") k("gamescope realtime", SessionPrefs.gamescopeRealtime(context)) k("pace cores", SessionPrefs.paceCores(context)) - k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) - k("native userland (no proot)", SessionPrefs.nativeUserland(context)) - k("proot fast path", SessionPrefs.prootFastPath(context)) + k("guest runtime policy", "native preferred with PRoot fallback") + k("guest runtime", when (com.droiddeck.launcher.runtime.NativeGuest.sessionMode) { + true -> "native" + false -> "PRoot" + null -> if (com.droiddeck.launcher.runtime.NativeGuest.enabled(context)) "native available" else "native unavailable" + }) k("proot binary", LinuxRuntime.prootSource(context) + " " + LinuxRuntime.prootBinary(context).path) k("proot fast path (eligible)", com.droiddeck.launcher.runtime.ProotFastPath.enabled(context)) k("Guest host name", SessionPrefs.guestHostname(context)) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt index 0577c2fece..d72274443b 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt @@ -577,12 +577,15 @@ object BwrapSpawner { private fun run(context: Context, plan: Plan, client: LocalSocket, out: DataOutputStream, id: Int) { val verbose = plan.env["DROIDDECK_PROOT_VERBOSE"]?.toIntOrNull() - val native = if (NativeGuest.forSession(context)) nativeLaunch(context, plan) else null + val nativeSession = NativeGuest.forSession(context) + val native = if (nativeSession) nativeLaunch(context, plan) else null val builder = if (native != null) { ProcessBuilder(native.first).redirectErrorStream(true) .directory(File(hostPath(plan.binds, plan.root.path, plan.cwd)).takeIf { it.isDirectory } ?: plan.root) .also { b -> b.environment().apply { clear(); putAll(native.second) } } } else { + val reason = if (nativeSession) "sandbox native launch unavailable" else "parent guest uses PRoot" + Log.i(TAG, "Flatpak: using PRoot ($reason)") val cmd = LinuxRuntime.prootPrefix(context, plan.root, plan.cwd) if (verbose != null) { cmd.add("-v"); cmd.add(verbose.toString()) } plan.binds.forEach { cmd.add("-b"); cmd.add(it.spec) } @@ -599,7 +602,6 @@ object BwrapSpawner { putAll(prootEnvironment(plan, envTool)) put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 6c0936e679..50a190c1ba 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -6,7 +6,6 @@ import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper import com.droiddeck.launcher.session.SessionFiles import com.droiddeck.launcher.session.SessionPaths -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.util.concurrent.atomic.AtomicBoolean @@ -67,7 +66,6 @@ object GuestCommand { put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) if (linkDir != null) put("PROOT_L2S_DIR", linkDir.path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> put(k, v) } } LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt index 6ad6a321c4..6e69ffe376 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt @@ -22,15 +22,15 @@ object NativeGuest { } fun enabled(context: Context): Boolean = - SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context)) + available(LinuxRuntime.rootDir(context)) /** * Whether the next session will start natively. The session stages the hook from the APK before - * it starts, so only the setting and the rootfs's loader decide, and a runtime still to be + * it starts, so the rootfs's loader decides, and a runtime still to be * installed will have one. */ fun nextSession(context: Context): Boolean = - SessionPrefs.nativeUserland(context) && willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context)) + willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context)) internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null @@ -39,7 +39,7 @@ object NativeGuest { /** * Whether a session's helpers (root commands, Flatpak sandboxes, installers) run natively: the - * session's own mode while one runs, as the setting can change under it and the rootfs is only + * session's own mode while one runs, as the rootfs is only * prepared for native programs at a session's start. */ fun forSession(context: Context): Boolean = sessionMode ?: enabled(context) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt index 27ef86f086..33fa897237 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt @@ -3,7 +3,6 @@ package com.droiddeck.launcher.runtime import android.content.Context import android.os.Build import android.util.Log -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.security.MessageDigest @@ -12,17 +11,14 @@ object ProotFastPath { const val LIBRARY = "/usr/local/lib/libddfastpath.so" const val MAX_BINDS = 256 - fun allows(preference: Boolean, noSeccomp: Boolean, source: String, nativeUserland: Boolean = false): Boolean = - preference && !noSeccomp && !nativeUserland && source == LinuxRuntime.PROOT_PACK + internal fun allows(source: String, native: Boolean): Boolean = + !native && source == LinuxRuntime.PROOT_PACK - fun enabled(context: Context): Boolean { - val preference = SessionPrefs.prootFastPath(context) - val noSeccomp = SessionPrefs.prootNoSeccomp(context) - val nativeUserland = SessionPrefs.nativeUserland(context) + fun enabled(context: Context, native: Boolean = NativeGuest.forSession(context)): Boolean { + if (native) return false val source = LinuxRuntime.prootSource(context) - val on = allows(preference, noSeccomp, source, nativeUserland) - if (preference && !noSeccomp && !nativeUserland && !on) - Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") + val on = allows(source, native) + if (!on) Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") return on } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt index 16228be728..1791df54b0 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt @@ -8,7 +8,6 @@ import android.os.Process import android.util.Log import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper -import com.droiddeck.launcher.session.SessionPrefs import org.json.JSONObject import java.io.DataInputStream import java.io.DataOutputStream @@ -128,7 +127,6 @@ object RootSpawner { clear() put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index 525844d880..dc708cb51d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -367,16 +367,17 @@ object SessionFiles { if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) { preload.append("/usr/local/lib/libfakeinput.so\n") } - val nativeUserland = SessionPrefs.nativeUserland(context) - if (nativeUserland) com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) - if (ProotFastPath.enabled(context)) { + com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) + val native = com.droiddeck.launcher.runtime.NativeGuest.available(root) + val nativePreload = preload.toString() + if (ProotFastPath.enabled(context, native)) { val library = com.droiddeck.launcher.agent.AgentEnv.fastPathLibrary(context) preload.append(library + "\n") if (startsSession && library != ProotFastPath.LIBRARY) Log.i(TAG, "fast path preload: $library (debugging override)") } val etc = File(root, "etc").apply { mkdirs() } File(etc, "droiddeck").mkdirs() - FileUtils.writeString(File(etc, "droiddeck/native-preload"), preload.toString()) + FileUtils.writeString(File(etc, "droiddeck/native-preload"), nativePreload) val staged = File(etc, "ld.so.preload.staged") if (!FileUtils.writeString(staged, preload.toString()) || !staged.renameTo(File(etc, "ld.so.preload"))) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index e42c8f48a5..523857654a 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -1181,21 +1181,9 @@ object SessionPrefs { prefs(context).edit().putBoolean("mountSharedStorage", on).apply() } - fun prootNoSeccomp(context: Context): Boolean = prefs(context).getBoolean("prootNoSeccomp", false) - - fun setProotNoSeccomp(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootNoSeccomp", on).apply() - } - - fun nativeUserland(context: Context): Boolean = prefs(context).getBoolean("nativeUserland", true) - /** The session's long-lived programs run in worker processes Android does not count (GuestWorkers). */ fun childProcessHandoff(context: Context): Boolean = prefs(context).getBoolean("childProcessHandoff", true) - fun setNativeUserland(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("nativeUserland", on).apply() - } - /** Whether the Plasma desktop, and so its apps and shells, runs as an ordinary user instead of root (native userland only). */ fun desktopAsUser(context: Context): Boolean = prefs(context).getBoolean("desktopAsUser", false) @@ -1203,12 +1191,6 @@ object SessionPrefs { prefs(context).edit().putBoolean("desktopAsUser", on).apply() } - fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true) - - fun setProotFastPath(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootFastPath", on).apply() - } - fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", true) fun setCursorComposite(context: Context, on: Boolean) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 3e53e37d75..fb6d3503f8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -47,6 +47,7 @@ import com.droiddeck.launcher.input.SteamControllerBle import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.runtime.NativeGuest import com.droiddeck.launcher.runtime.ProotFastPath import com.droiddeck.launcher.runtime.UserApps import com.droiddeck.launcher.wayland.WaylandCompositor @@ -784,12 +785,13 @@ class SessionService : Service() { SessionEvents.step("shm-clear") { FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm")) } val sharedStorage = LinuxRuntime.sharedStorage(this) - val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage) - val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this) + val nativeUserland = NativeGuest.enabled(this) + val fastPath = ProotFastPath.enabled(this, nativeUserland) + val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage, fastPath) synchronized(stopLock) { if (gen == sessionGen && SessionState.running) com.droiddeck.launcher.runtime.NativeGuest.sessionMode = nativeUserland } - val fastPathKey = if (ProotFastPath.enabled(this)) { + val fastPathKey = if (fastPath) { val prootBinds = LinuxRuntime.binds( this, sessionRoot, runtimeDir, sharedStorage, binds, ) @@ -810,16 +812,14 @@ class SessionService : Service() { LinuxRuntime.rememberSessionBinds(sessionBindSpecs) com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1)) } else { + val reason = if (NativeGuest.loader(root) == null) "missing glibc loader" else "missing native hook" + Log.i(TAG, "guest runtime: using PRoot ($reason)") LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, guest) } val prootEnv = HostEnvironment() prootEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path prootEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path - if (SessionPrefs.prootNoSeccomp(this)) { - prootEnv["PROOT_NO_SECCOMP"] = "1" - if (!nativeUserland) Log.i(TAG, "proot: seccomp acceleration off by request") - } fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> prootEnv[k] = v } } for (key in listOf("PROOT_PROFILE", "PROOT_PROFILE_SLOW_US")) { guest.lastOrNull { it.startsWith("$key=") }?.substringAfter('=')?.let { prootEnv[key] = it } @@ -1313,6 +1313,7 @@ class SessionService : Service() { sessionRoot: File, runtimeDir: File, sharedStorage: File?, + fastPath: Boolean, ): ArrayList { val binds = ArrayList() if (controllersOn) binds.add(fakeInputDir.path + ":/dev/input") @@ -1446,7 +1447,7 @@ class SessionService : Service() { if (storageDiagnosticLibrary != null && library != null) libraries.add(SecondaryLibrary.CARD_GUESTS[0] to library.label) val gamesLibraries = GameStorage.gamesFolderLibraries(this) if (gamesLibraries.isNotEmpty()) { - var room = if (ProotFastPath.enabled(this)) { + var room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (games in gamesLibraries) { @@ -1488,7 +1489,7 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val content = SecondaryLibrary.contentPath(entry.host) @@ -1517,7 +1518,7 @@ class SessionService : Service() { if (problem != null) { Log.w(TAG, "x86-64 steam library: $problem") } else try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, x64, listOf(GameStorage.X64_CARD_GUEST)).drop(1) @@ -1539,7 +1540,7 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, entry.x64Host, listOf(entry.x64Guest)).drop(1) @@ -1575,7 +1576,7 @@ class SessionService : Service() { try { val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() } val volumes = org.json.JSONArray() - var room = if (ProotFastPath.enabled(this)) { + var room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt index 6f77df7990..56e8d6e128 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt @@ -8,7 +8,6 @@ import androidx.compose.runtime.setValue import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.SessionEvents -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.stores.Store import com.droiddeck.launcher.stores.AchievementNotifications @@ -149,7 +148,6 @@ object GogComet { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index 07d47c78cd..6be4ddb14e 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -5,7 +5,6 @@ import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.ProotFastPath -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.StoreInstallRoot import org.json.JSONObject import java.io.Closeable @@ -107,7 +106,6 @@ internal object Xodus { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } } LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt index 69aa3c6f97..45edd262af 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -46,9 +46,7 @@ fun PerformancePage( fsyncFirst: Boolean, gamescopeRealtime: Boolean, gpuClockPin: Boolean, - prootNoSeccomp: Boolean, - prootFastPath: Boolean, - nativeUserland: Boolean, + nativeDesktopAvailable: Boolean, desktopAsUser: Boolean, cursorComposite: Boolean, guestHostname: String, @@ -65,9 +63,6 @@ fun PerformancePage( onFsyncFirst: (Boolean) -> Unit, onGamescopeRealtime: (Boolean) -> Unit, onGpuClockPin: (Boolean) -> Unit, - onProotNoSeccomp: (Boolean) -> Unit, - onProotFastPath: (Boolean) -> Unit, - onNativeUserland: (Boolean) -> Unit, onDesktopAsUser: (Boolean) -> Unit, onCursorComposite: (Boolean) -> Unit, onGuestHostname: (String) -> Unit, @@ -152,26 +147,6 @@ fun PerformancePage( stringResource(R.string.perf_fastsync_hint), fastSync, onChange = onFastSync, ) - ToggleRow( - host, "seccomp", stringResource(R.string.perf_seccomp), - stringResource(R.string.perf_seccomp_hint), - prootNoSeccomp, onChange = onProotNoSeccomp, - ) - ToggleRow( - host, "fastpath", stringResource(R.string.perf_fastpath), - when { - nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot) - prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp) - else -> stringResource(R.string.perf_fastpath_hint) - }, - prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland, - onChange = onProotFastPath, - ) - ToggleRow( - host, "nativeuserland", stringResource(R.string.perf_native_userland), - stringResource(R.string.perf_native_userland_hint), - nativeUserland, onChange = onNativeUserland, - ) ToggleRow( host, "cursorcomposite", stringResource(R.string.perf_cursor_composite), stringResource(R.string.perf_cursor_composite_hint), @@ -198,8 +173,8 @@ fun PerformancePage( } ToggleRow( host, "desktopasuser", stringResource(R.string.perf_desktop_as_user), - stringResource(if (nativeUserland) R.string.perf_desktop_as_user_hint else R.string.perf_desktop_as_user_needs_native), - desktopAsUser && nativeUserland, enabled = nativeUserland, + stringResource(R.string.perf_desktop_as_user_hint), + desktopAsUser && nativeDesktopAvailable, enabled = nativeDesktopAvailable, onChange = onDesktopAsUser, ) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt index 2bd881af35..4359813c07 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt @@ -85,9 +85,6 @@ internal object SettingsIndex { s(SettingsSection.PERFORMANCE, R.string.perf_esync, "esync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fsync, "fsync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fastsync, "ntsync", "sync", "wine"), - s(SettingsSection.PERFORMANCE, R.string.perf_seccomp, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_fastpath, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_native_userland, "proot"), s(SettingsSection.PERFORMANCE, R.string.perf_cursor_composite, "mouse", "cursor"), s(SettingsSection.PERFORMANCE, R.string.perf_hostname, "name"), s(SettingsSection.PERFORMANCE, R.string.perf_desktop_as_user, "root", "user", "sudo", "fakeroot"), diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestDefaultsTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestDefaultsTest.kt new file mode 100644 index 0000000000..fd4b629e7a --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/runtime/NativeGuestDefaultsTest.kt @@ -0,0 +1,38 @@ +package com.droiddeck.launcher.runtime + +import android.content.Context +import java.io.File +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment + +@RunWith(RobolectricTestRunner::class) +class NativeGuestDefaultsTest { + @Test fun savedRuntimeOverridesDoNotDisableNativeExecution() { + val context = RuntimeEnvironment.getApplication() + context.getSharedPreferences("session", Context.MODE_PRIVATE).edit() + .putBoolean("nativeUserland", false) + .putBoolean("prootFastPath", false) + .putBoolean("prootNoSeccomp", true) + .apply() + + val root = LinuxRuntime.rootDir(context) + val hook = NativeGuest.hook(root) + val loader = File(root, "usr/lib/ld-linux-aarch64.so.1") + hook.parentFile?.mkdirs() + loader.writeText("fixture") + try { + assertTrue(NativeGuest.nextSession(context)) + assertFalse(NativeGuest.enabled(context)) + hook.writeText("fixture") + assertTrue(NativeGuest.enabled(context)) + assertFalse(ProotFastPath.enabled(context, native = true)) + } finally { + hook.delete() + loader.delete() + } + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/ProotFastPathTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/ProotFastPathTest.kt index f413618942..24da684e49 100644 --- a/app/src/test/java/com/droiddeck/launcher/runtime/ProotFastPathTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/runtime/ProotFastPathTest.kt @@ -27,14 +27,12 @@ class ProotFastPathTest { } @Test fun fastPathStaysOffForTheRootfsProot() { - assertTrue(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_PACK)) - assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_ROOTFS)) - assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_MISSING)) - assertFalse(ProotFastPath.allows(preference = false, noSeccomp = false, source = LinuxRuntime.PROOT_PACK)) - assertFalse(ProotFastPath.allows(preference = true, noSeccomp = true, source = LinuxRuntime.PROOT_PACK)) + assertTrue(ProotFastPath.allows(source = LinuxRuntime.PROOT_PACK, native = false)) + assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_ROOTFS, native = false)) + assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_MISSING, native = false)) } @Test fun fastPathStaysOffWithoutProot() { - assertFalse(ProotFastPath.allows(preference = true, noSeccomp = false, source = LinuxRuntime.PROOT_PACK, nativeUserland = true)) + assertFalse(ProotFastPath.allows(source = LinuxRuntime.PROOT_PACK, native = true)) } } diff --git a/docs/settings-map.md b/docs/settings-map.md index b38a8fdf9f..66ad66d802 100644 --- a/docs/settings-map.md +++ b/docs/settings-map.md @@ -27,9 +27,6 @@ Links of the form `droiddeck://settings/
` open a Settings section direc | droiddeck-esync | Settings › Performance (`droiddeck://settings/performance`) | esync, sync, wine | | droiddeck-fsync first | Settings › Performance (`droiddeck://settings/performance`) | fsync, sync, wine | | droiddeck-ntsync | Settings › Performance (`droiddeck://settings/performance`) | ntsync, sync, wine | -| Run proot without seccomp | Settings › Performance (`droiddeck://settings/performance`) | proot | -| proot fast path | Settings › Performance (`droiddeck://settings/performance`) | proot | -| Run without proot (experimental) | Settings › Performance (`droiddeck://settings/performance`) | proot | | Draw the cursor inside gamescope | Settings › Performance (`droiddeck://settings/performance`) | mouse, cursor | | Host name | Settings › Performance (`droiddeck://settings/performance`) | name | | Desktop runs as a user | Settings › Performance (`droiddeck://settings/performance`) | root, user, sudo, fakeroot |