mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-01 10:35:43 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b70199bf4d |
No files matched your search
@@ -325,7 +325,7 @@ object BwrapSpawner {
|
||||
private const val PRELOAD_DIR = "/run/droiddeck-preload"
|
||||
private const val NET_LINK = "etc/droiddeck-net"
|
||||
|
||||
private const val ZYPAK_SHIM = "#!/bin/sh\nprogram=\$1\nshift\nexec \"\$program\" --no-sandbox \"\$@\"\n"
|
||||
private const val ZYPAK_SHIM = "#!/bin/sh\nprogram=\$1\nshift\nif [ -n \"\${ELECTRON_RUN_AS_NODE:-}\" ]; then\n exec \"\$program\" \"\$@\"\nfi\nexec \"\$program\" --no-sandbox \"\$@\"\n"
|
||||
|
||||
private fun zypakShims(binds: List<Bind>, root: File, dir: File): List<Bind> {
|
||||
val wrappers = listOf("/app/bin/zypak-wrapper.sh", "/app/bin/zypak-wrapper").filter { guest ->
|
||||
|
||||
@@ -263,6 +263,21 @@ class BwrapSpawnerPlanTest {
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
fun runShim(mode: String?, program: String): List<String> {
|
||||
val executable = File(dir, program).apply { writeText("#!/bin/sh\nprintf '%s\\n' \"\$@\"\n"); setExecutable(true) }
|
||||
val process = ProcessBuilder("/bin/sh", shim.host, executable.path, "argument with spaces", "--user-flag")
|
||||
if (mode == null) process.environment().remove("ELECTRON_RUN_AS_NODE")
|
||||
else process.environment()["ELECTRON_RUN_AS_NODE"] = mode
|
||||
val child = process.start()
|
||||
val output = child.inputStream.bufferedReader().readLines()
|
||||
assertEquals(0, child.waitFor())
|
||||
return output
|
||||
}
|
||||
val args = listOf("argument with spaces", "--user-flag")
|
||||
assertEquals(args, runShim("1", "code"))
|
||||
assertEquals(args, runShim("0", "another-electron-app"))
|
||||
assertEquals(listOf("--no-sandbox") + args, runShim(null, "code"))
|
||||
assertEquals(listOf("--no-sandbox") + args, runShim("", "another-electron-app"))
|
||||
assertFalse(plan.binds.any { it.guest == "/app/bin/zypak-wrapper" })
|
||||
assertTrue(File(app, "bin/zypak-wrapper.sh").readText().contains("zypak-helper"))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user