From f5e496996437243bdf3c62a48b938992bea0ee15 Mon Sep 17 00:00:00 2001 From: Yos-X Date: Tue, 13 Oct 2026 17:28:34 +0800 Subject: [PATCH] internal: Deny the device tree on the hosts that have one The floor denies /dev on every host. On a host without a device tree that path is \dev, which names no root of its own, so no check can canonicalize it and the floor cannot be built: AgentFloor is made of those roots, so the agent plugin is not created at all and everything that starts the runtime fails on such a host. The device tree is a root where there is one, so it is denied where the host separates paths with a slash and nowhere else. --- .../alexandrite/internal/floor/Floor.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/internal/src/main/kotlin/org/foedusprogramme/alexandrite/internal/floor/Floor.kt b/libraries/internal/src/main/kotlin/org/foedusprogramme/alexandrite/internal/floor/Floor.kt index 90640b69..56c3f07a 100644 --- a/libraries/internal/src/main/kotlin/org/foedusprogramme/alexandrite/internal/floor/Floor.kt +++ b/libraries/internal/src/main/kotlin/org/foedusprogramme/alexandrite/internal/floor/Floor.kt @@ -189,7 +189,16 @@ private fun isMagic(path: CanonicalPath): Boolean { private fun standardRoots(home: Path?, environment: Map): List = home?.let { CREDENTIAL_STORES.map { (name, kind) -> DenyRoot(home.resolve(name), kind) } }.orEmpty() + movedStores(environment) + - DenyRoot(Path.of("/dev"), "devices") + DEVICES + +/** + * The device tree, on the hosts that have one. + * + * `/dev` is the device tree of a POSIX system and means nothing on a host without one: there it names a path that has + * no root of its own, which no check can canonicalize. + */ +private val DEVICES: List = + if (java.io.File.separatorChar == '/') listOf(DenyRoot(Path.of("/dev"), "devices")) else emptyList() /** The credential stores at the absolute places that the variables of [environment] name. */ private fun movedStores(environment: Map): List {