From 3f2837a5fc845c5eb3df9a85d3dc42e9d5056fe6 Mon Sep 17 00:00:00 2001 From: Dongni Yang Date: Thu, 6 Aug 2026 13:44:40 +0800 Subject: [PATCH 1/2] fix(onboard): keep the portable firewall driver in the podman search path The portable profile wrote its network settings to a private path and reached them only through CONTAINERS_CONF. Podman ignores every system and user config file when CONTAINERS_CONF is set, and `systemctl --user set-environment` drops that variable when the user manager restarts, so a new session lost `firewall_driver` and netavark fell back to nftables with no `nft` binary present. Write the same settings to the `containers.conf.d` drop-in that podman already reads from its own default search path, alongside the existing `registries.conf.d` fragment. Refs #8441 Signed-off-by: Dongni Yang --- .../portable-host-preparation.test.ts | 25 +++++++++++++++++++ .../experimental/portable-host-preparation.ts | 8 ++++++ 2 files changed, 33 insertions(+) diff --git a/src/lib/onboard/experimental/portable-host-preparation.test.ts b/src/lib/onboard/experimental/portable-host-preparation.test.ts index 3216de5771e..9cacc1d1df7 100644 --- a/src/lib/onboard/experimental/portable-host-preparation.test.ts +++ b/src/lib/onboard/experimental/portable-host-preparation.test.ts @@ -101,6 +101,31 @@ describe("preparePortableExperimentalHost", () => { expect(fs.statSync(containersConf).mode & 0o777).toBe(0o600); }); + it("keeps the portable firewall driver in the podman default search path (#8441)", () => { + const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-portable-")); + tempDirs.push(home); + const systemctl = vi.fn<(args: readonly string[], env: NodeJS.ProcessEnv) => SpawnResult>(() => + result(), + ); + const docker = vi + .fn<(args: readonly string[], env: NodeJS.ProcessEnv) => SpawnResult>() + .mockReturnValueOnce(result(1)) + .mockReturnValueOnce(result()); + const podman = vi.fn(() => result(0, "/run/user/1001/podman/podman.sock\n")); + + preparePortableExperimentalHost( + { NEMOCLAW_EXPERIMENTAL_PROFILE: "portable" }, + { platform: "linux", home, uid: 1001, systemctl, podman, docker }, + ); + + const dropIn = path.join( + home, + ".config/containers/containers.conf.d/99-nemoclaw-portable.conf", + ); + expect(fs.readFileSync(dropIn, "utf-8")).toContain('firewall_driver = "iptables"'); + expect(fs.statSync(dropIn).mode & 0o777).toBe(0o600); + }); + it("refuses to replace an unmanaged registry container", () => { const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-portable-")); tempDirs.push(home); diff --git a/src/lib/onboard/experimental/portable-host-preparation.ts b/src/lib/onboard/experimental/portable-host-preparation.ts index 58307c5dc10..f6342d6225e 100644 --- a/src/lib/onboard/experimental/portable-host-preparation.ts +++ b/src/lib/onboard/experimental/portable-host-preparation.ts @@ -87,6 +87,14 @@ function writePortableRuntimeConfig(home: string, env: NodeJS.ProcessEnv): strin path.join(configHome, "containers", "registries.conf.d", "99-nemoclaw-portable.conf"), REGISTRY_FRAGMENT, ); + // Podman reads `containers.conf.d` drop-ins from its own default search path, so this copy + // keeps `firewall_driver` in effect for a shell that starts without CONTAINERS_CONF. The + // `systemctl --user set-environment` values below last only until the user manager restarts. + writePrivateConfig( + path.join(configHome, "containers", "containers.conf.d", "99-nemoclaw-portable.conf"), + PORTABLE_CONTAINERS_CONF, + ); + // Read through CONTAINERS_CONF by the OpenShell gateway service environment. const containersConf = path.join(configHome, "nemoclaw", "portable", "containers.conf"); writePrivateConfig(containersConf, PORTABLE_CONTAINERS_CONF); return containersConf; From 68dd8d69867f8524259bfec0c3179850857cd79c Mon Sep 17 00:00:00 2001 From: Dongni Yang Date: Thu, 6 Aug 2026 14:12:54 +0800 Subject: [PATCH 2/2] fix(onboard): name both CONTAINERS_CONF readers in the portable comment Signed-off-by: Dongni Yang --- .../onboard/experimental/portable-host-preparation.test.ts | 2 +- src/lib/onboard/experimental/portable-host-preparation.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/onboard/experimental/portable-host-preparation.test.ts b/src/lib/onboard/experimental/portable-host-preparation.test.ts index 9cacc1d1df7..4acbe182466 100644 --- a/src/lib/onboard/experimental/portable-host-preparation.test.ts +++ b/src/lib/onboard/experimental/portable-host-preparation.test.ts @@ -101,7 +101,7 @@ describe("preparePortableExperimentalHost", () => { expect(fs.statSync(containersConf).mode & 0o777).toBe(0o600); }); - it("keeps the portable firewall driver in the podman default search path (#8441)", () => { + it("keeps the portable firewall driver in the Podman default search path (#8441)", () => { const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-portable-")); tempDirs.push(home); const systemctl = vi.fn<(args: readonly string[], env: NodeJS.ProcessEnv) => SpawnResult>(() => diff --git a/src/lib/onboard/experimental/portable-host-preparation.ts b/src/lib/onboard/experimental/portable-host-preparation.ts index f6342d6225e..e3f46df3c88 100644 --- a/src/lib/onboard/experimental/portable-host-preparation.ts +++ b/src/lib/onboard/experimental/portable-host-preparation.ts @@ -87,14 +87,14 @@ function writePortableRuntimeConfig(home: string, env: NodeJS.ProcessEnv): strin path.join(configHome, "containers", "registries.conf.d", "99-nemoclaw-portable.conf"), REGISTRY_FRAGMENT, ); - // Podman reads `containers.conf.d` drop-ins from its own default search path, so this copy + // Podman reads `containers.conf.d` drop-ins from its own default search path, so this drop-in // keeps `firewall_driver` in effect for a shell that starts without CONTAINERS_CONF. The // `systemctl --user set-environment` values below last only until the user manager restarts. writePrivateConfig( path.join(configHome, "containers", "containers.conf.d", "99-nemoclaw-portable.conf"), PORTABLE_CONTAINERS_CONF, ); - // Read through CONTAINERS_CONF by the OpenShell gateway service environment. + // The OpenShell gateway service and sandbox prebuild read this file through CONTAINERS_CONF. const containersConf = path.join(configHome, "nemoclaw", "portable", "containers.conf"); writePrivateConfig(containersConf, PORTABLE_CONTAINERS_CONF); return containersConf;