Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Keep proxy and non-interactive env through sudo in sandboxes (#2511)

Regan Bell62fc39241bff
diff --git a/src/sandbox/agent37-sandbox.ts b/src/sandbox/agent37-sandbox.ts
index 6078a4d6b..6d36ab8c8 100644
--- a/src/sandbox/agent37-sandbox.ts
+++ b/src/sandbox/agent37-sandbox.ts
@@ -6,7 +6,7 @@ import { createKeyedQueue, fetchWithRetry, sleep } from "../util/async.ts";
import { withRequestId, swallowAs, errMessage } from "../util/errors.ts";
import { NonRetryableTurnError } from "../core/turn-error.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix } from "./sandbox-env.ts";
+import { nonInteractiveShellPrefix, provisionPrepScript } from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createExecExport, createBackendBlobStaging, createExecFileOps, posixJoin } from "./exec-file-ops.ts";
@@ -528,8 +528,8 @@ export function createAgent37Sandbox(workspace: WorkspaceStore, opts: Agent37San
};
try {
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? [])}`;
- const prep = await execRaw(name, `mkdir -p ${shq(workspaceDir)}${credLinks}`, 60);
+ const credLinks = scratch ? null : ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? []);
+ const prep = await execRaw(name, provisionPrepScript(workspaceDir, credLinks), 60);
if (prep.code !== 0)
throw new Error(`agent37 provision prep failed: ${(prep.stderr || prep.stdout).slice(0, 200)}`);
diff --git a/src/sandbox/aws-sandbox.ts b/src/sandbox/aws-sandbox.ts
index 9bf1419a0..18c068799 100644
--- a/src/sandbox/aws-sandbox.ts
+++ b/src/sandbox/aws-sandbox.ts
@@ -9,7 +9,7 @@ import { createKeyedQueue } from "../util/async.ts";
import { scopeStorageKey } from "../../cli/src/scope-storage-key.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix } from "./sandbox-env.ts";
+import { nonInteractiveShellPrefix, provisionPrepScript } from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import {
@@ -439,7 +439,7 @@ export function createAwsSandbox(workspace: WorkspaceStore, opts: AwsSandboxOpti
try {
const prepared = await execRaw(
id,
- `mkdir -p ${shq(WORKSPACE_DIR)} && ${ephemeralCredLinkScript(HOME_DIR, credentialPaths)}`,
+ provisionPrepScript(WORKSPACE_DIR, ephemeralCredLinkScript(HOME_DIR, credentialPaths)),
PREP_TIMEOUT_SEC,
);
if (prepared.code !== 0)
diff --git a/src/sandbox/e2b-sandbox.ts b/src/sandbox/e2b-sandbox.ts
index c2a7ab9ff..f31c194ea 100644
--- a/src/sandbox/e2b-sandbox.ts
+++ b/src/sandbox/e2b-sandbox.ts
@@ -7,7 +7,12 @@ import type { AdvisoryLock } from "../persistence/advisory-lock.ts";
import { createKeyedQueue } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, forceThroughProxyEnv } from "./sandbox-env.ts";
+import {
+ nonInteractiveShellPrefix,
+ DROPPED_PROXY_ENV,
+ forceThroughProxyEnv,
+ provisionPrepScript,
+} from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createLayerToolInstaller } from "./layer-tool-install.ts";
@@ -431,8 +436,8 @@ export function createE2bSandbox(workspace: WorkspaceStore, opts: E2bSandboxOpti
};
try {
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? [])}`;
- const prep = await execRaw(name, `mkdir -p ${shq(workspaceDir)}${credLinks}`, 60);
+ const credLinks = scratch ? null : ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? []);
+ const prep = await execRaw(name, provisionPrepScript(workspaceDir, credLinks), 60);
if (prep.code !== 0)
throw new Error(`e2b provision prep failed: ${(prep.stderr || prep.stdout).slice(0, 200)}`);
diff --git a/src/sandbox/exec-sandbox-base.ts b/src/sandbox/exec-sandbox-base.ts
index fa6c8eb62..3a3ce94e6 100644
--- a/src/sandbox/exec-sandbox-base.ts
+++ b/src/sandbox/exec-sandbox-base.ts
@@ -6,7 +6,12 @@ import { createKeyedQueue } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
import { shortHash } from "../util/crypto.ts";
-import { DROPPED_PROXY_ENV, forceThroughProxyEnv, nonInteractiveShellPrefix } from "./sandbox-env.ts";
+import {
+ DROPPED_PROXY_ENV,
+ forceThroughProxyEnv,
+ nonInteractiveShellPrefix,
+ provisionPrepScript,
+} from "./sandbox-env.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import type { LayerToolInstaller } from "./layer-tool-install.ts";
import { posixJoin } from "./exec-file-ops.ts";
@@ -189,8 +194,8 @@ export function createExecSandboxBase(deps: ExecSandboxBaseDeps): ExecSandboxBas
);
const env = forceEgress ? forceThroughProxyEnv(deps.egressProxyUrl!, provOpts!.egressToken!, turnEnv) : turnEnv;
if (Object.keys(env).length) handle.env = env;
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(homeDir, deps.credentialPaths)}`;
- const prepare = `mkdir -p ${shq(workspaceDir)}${credLinks}`;
+ const credLinks = scratch ? null : ephemeralCredLinkScript(homeDir, deps.credentialPaths);
+ const prepare = provisionPrepScript(workspaceDir, credLinks);
const toolIo = {
exec: (script: string, t: number) => deps.exec(name, script, t),
writeAbs: (abs: string, data: Uint8Array) => deps.writeAbsBytes(name, abs, data),
diff --git a/src/sandbox/local-sandbox.ts b/src/sandbox/local-sandbox.ts
index 1abb003d6..4451c81fd 100644
--- a/src/sandbox/local-sandbox.ts
+++ b/src/sandbox/local-sandbox.ts
@@ -9,7 +9,7 @@ import type { WorkspaceStore } from "../workspace/workspace-store.ts";
import { createKeyedQueue, sleep } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix } from "./sandbox-env.ts";
+import { nonInteractiveShellPrefix, provisionPrepScript } from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createExecExport, createExecFileOps, posixJoin } from "./exec-file-ops.ts";
@@ -404,7 +404,7 @@ export function createLocalSandbox(workspace: WorkspaceStore, opts: LocalSandbox
try {
const prep = await execRaw(
name,
- `mkdir -p ${shq(workspaceDir)} && ${ephemeralCredLinkScript(homeDir)}`,
+ provisionPrepScript(workspaceDir, ephemeralCredLinkScript(homeDir)),
PREP_TIMEOUT_SEC,
);
if (prep.code !== 0)
diff --git a/src/sandbox/managed-agents-sandbox.ts b/src/sandbox/managed-agents-sandbox.ts
index 2c64d0df5..cea46cf94 100644
--- a/src/sandbox/managed-agents-sandbox.ts
+++ b/src/sandbox/managed-agents-sandbox.ts
@@ -6,7 +6,12 @@ import type { DurableMap } from "../persistence/durable-map.ts";
import { createKeyedQueue } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, forceThroughProxyEnv } from "./sandbox-env.ts";
+import {
+ nonInteractiveShellPrefix,
+ DROPPED_PROXY_ENV,
+ forceThroughProxyEnv,
+ provisionPrepScript,
+} from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createLayerToolInstaller } from "./layer-tool-install.ts";
@@ -434,8 +439,8 @@ export function createManagedAgentsSandbox(workspace: WorkspaceStore, opts: Mana
};
try {
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? [])}`;
- const prep = await execRaw(name, `mkdir -p ${shq(workspaceDir)}${credLinks}`, 60);
+ const credLinks = scratch ? null : ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? []);
+ const prep = await execRaw(name, provisionPrepScript(workspaceDir, credLinks), 60);
if (prep.code !== 0)
throw new Error(`do-managed-agents provision prep failed: ${(prep.stderr || prep.stdout).slice(0, 200)}`);
diff --git a/src/sandbox/modal-sandbox.ts b/src/sandbox/modal-sandbox.ts
index 5dd4e32c3..a78312f88 100644
--- a/src/sandbox/modal-sandbox.ts
+++ b/src/sandbox/modal-sandbox.ts
@@ -8,7 +8,12 @@ import { orgId as configOrgId } from "../config.ts";
import { createKeyedQueue } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, forceThroughProxyEnv } from "./sandbox-env.ts";
+import {
+ nonInteractiveShellPrefix,
+ DROPPED_PROXY_ENV,
+ forceThroughProxyEnv,
+ provisionPrepScript,
+} from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { withConnectorSdk, type ConnectorSdkBundle } from "./connector-sdk.ts";
@@ -713,13 +718,13 @@ export function createModalSandbox(workspace: WorkspaceStore, opts: ModalSandbox
};
try {
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? [])}`;
+ const credLinks = scratch ? null : ephemeralCredLinkScript(HOME_DIR, opts.credentialPaths ?? []);
await installLayerTools(
{
exec: (script, t) => execRaw(name, script, t),
writeAbs: (abs, data) => writeAbsBytes(name, abs, data),
},
- `mkdir -p ${shq(workspaceDir)}${credLinks}`,
+ provisionPrepScript(workspaceDir, credLinks),
);
await materializeRoLayers(
diff --git a/src/sandbox/porter-sandbox.ts b/src/sandbox/porter-sandbox.ts
index 33631ab36..48988643f 100644
--- a/src/sandbox/porter-sandbox.ts
+++ b/src/sandbox/porter-sandbox.ts
@@ -19,7 +19,12 @@ import {
type PorterSandboxLike,
} from "./porter-client.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, forceThroughProxyEnv } from "./sandbox-env.ts";
+import {
+ nonInteractiveShellPrefix,
+ DROPPED_PROXY_ENV,
+ forceThroughProxyEnv,
+ provisionPrepScript,
+} from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createExecExport, createBackendBlobStaging, createExecFileOps, posixJoin } from "./exec-file-ops.ts";
@@ -308,8 +313,8 @@ export function createPorterSandbox(workspace: WorkspaceStore, opts: PorterSandb
};
try {
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(homeDir, opts.credentialPaths ?? [])}`;
- const prep = await execRaw(name, `mkdir -p ${shq(workspaceDir)}${credLinks}`, 60);
+ const credLinks = scratch ? null : ephemeralCredLinkScript(homeDir, opts.credentialPaths ?? []);
+ const prep = await execRaw(name, provisionPrepScript(workspaceDir, credLinks), 60);
if (prep.code !== 0)
throw new Error(`porter provision prep failed: ${(prep.stderr || prep.stdout).slice(0, 200)}`);
diff --git a/src/sandbox/sandbox-env.ts b/src/sandbox/sandbox-env.ts
index e93fff2dd..840337035 100644
--- a/src/sandbox/sandbox-env.ts
+++ b/src/sandbox/sandbox-env.ts
@@ -27,6 +27,18 @@ export const DROPPED_PROXY_ENV = new Set([
"NO_PROXY",
]);
+const SUDO_KEPT_ENV = ["DEBIAN_FRONTEND", "GIT_TERMINAL_PROMPT", ...DROPPED_PROXY_ENV, "GIT_HTTP_PROXY_AUTHMETHOD"];
+
+const SUDOERS_KEEP_ENV = shq(`Defaults env_keep += "${SUDO_KEPT_ENV.join(" ")}"`);
+
+const SUDO_KEEPS_ENV =
+ `[ ! -d /etc/sudoers.d ] || [ -s /etc/sudoers.d/qm-env ] || ` +
+ `printf '%s\\n' ${SUDOERS_KEEP_ENV} | sudo -n sh -c 'umask 337; cat > /etc/sudoers.d/qm-env' 2>/dev/null || true`;
+
+export function provisionPrepScript(workspaceDir: string, credLinks: string | null): string {
+ return `mkdir -p ${shq(workspaceDir)}${credLinks ? ` && ${credLinks}` : ""} && { ${SUDO_KEEPS_ENV}; }`;
+}
+
export function forceThroughProxyEnv(
egressProxyUrl: string,
token: string,
diff --git a/src/sandbox/superserve-sandbox.ts b/src/sandbox/superserve-sandbox.ts
index cd40e5c80..4affdd87d 100644
--- a/src/sandbox/superserve-sandbox.ts
+++ b/src/sandbox/superserve-sandbox.ts
@@ -8,7 +8,7 @@ import type { AdvisoryLock } from "../persistence/advisory-lock.ts";
import { createKeyedQueue } from "../util/async.ts";
import { swallowAs, errMessage } from "../util/errors.ts";
import { shq } from "../util/shell.ts";
-import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV } from "./sandbox-env.ts";
+import { nonInteractiveShellPrefix, DROPPED_PROXY_ENV, provisionPrepScript } from "./sandbox-env.ts";
import { createExecProcessSessions, type ExecProcessIo } from "./exec-process-session.ts";
import { materializeRoLayers } from "./ro-layers.ts";
import { createLayerToolInstaller } from "./layer-tool-install.ts";
@@ -587,8 +587,8 @@ export function createSuperserveSandbox(workspace: WorkspaceStore, opts: Superse
const prepare = async (): Promise<SandboxHandle> => {
assertCurrent(handle);
if (!(await ownsGuest(name))) return handle;
- const credLinks = scratch ? "" : ` && ${ephemeralCredLinkScript(homeDir, opts.credentialPaths ?? [])}`;
- const prep = await execRaw(name, `mkdir -p ${shq(workspaceDir)}${credLinks}`, PREP_TIMEOUT_SEC);
+ const credLinks = scratch ? null : ephemeralCredLinkScript(homeDir, opts.credentialPaths ?? []);
+ const prep = await execRaw(name, provisionPrepScript(workspaceDir, credLinks), PREP_TIMEOUT_SEC);
if (prep.code !== 0)
throw new Error(`superserve provision prep failed: ${(prep.stderr || prep.stdout).slice(0, 200)}`);
await materializeRoLayers(
diff --git a/test/local-sandbox.test.ts b/test/local-sandbox.test.ts
index 92bb43e0a..15c36e7e5 100644
--- a/test/local-sandbox.test.ts
+++ b/test/local-sandbox.test.ts
@@ -1,7 +1,7 @@
import { test, before, after } from "node:test";
import assert from "node:assert/strict";
import { spawn, type ChildProcess } from "node:child_process";
-import { mkdtempSync } from "node:fs";
+import { mkdtempSync, writeFileSync } from "node:fs";
import { createServer, type AddressInfo } from "node:net";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -32,10 +32,21 @@ async function freePort(): Promise<number> {
});
}
+function refusingSudoDir(): string {
+ const bin = mkdtempSync(join(tmpdir(), "refusing-sudo-"));
+ writeFileSync(join(bin, "sudo"), "#!/bin/sh\nexit 1\n", { mode: 0o755 });
+ return bin;
+}
+
before(async () => {
daemonPort = await freePort();
daemon = spawn(process.execPath, [join(process.cwd(), "cli/templates/aws/microvm-agent/agent.mjs")], {
- env: { ...process.env, AGENT_PORT: String(daemonPort), HOME: guestHome },
+ env: {
+ ...process.env,
+ AGENT_PORT: String(daemonPort),
+ HOME: guestHome,
+ PATH: `${refusingSudoDir()}:${process.env.PATH}`,
+ },
stdio: "ignore",
});
const deadline = Date.now() + 10_000;
diff --git a/test/sandbox-noninteractive.test.ts b/test/sandbox-noninteractive.test.ts
index 25301aef3..6372fdda9 100644
--- a/test/sandbox-noninteractive.test.ts
+++ b/test/sandbox-noninteractive.test.ts
@@ -1,6 +1,6 @@
import { test, before, after } from "node:test";
import assert from "node:assert/strict";
-import { mkdtempSync } from "node:fs";
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createSpritesSandbox } from "../src/sandbox/sprites-sandbox.ts";
@@ -63,3 +63,25 @@ test("an explicit per-turn env value wins over the non-interactive default", asy
const r = await sandbox.run(handle, 'printf "%s" "$PAGER"');
assert.equal(r.stdout, "less");
});
+
+test("provisioning installs a sudoers env_keep entry so sudo keeps the proxy and non-interactive env", async () => {
+ const bin = mkdtempSync(join(tmpdir(), "nopass-sudo-"));
+ writeFileSync(join(bin, "sudo"), '#!/bin/sh\nwhile [ "${1#-}" != "$1" ]; do shift; done\nexec "$@"\n');
+ chmodSync(join(bin, "sudo"), 0o755);
+ const path = process.env.PATH;
+ process.env.PATH = `${bin}:${path}`;
+ try {
+ const { sandbox, layers } = spritesHandle();
+ const first = await sandbox.provision(layers);
+ const sudoersDir = join(ff.homeDir(first.id), ".etc-sudoers.d");
+ assert.equal(existsSync(sudoersDir), false);
+ mkdirSync(sudoersDir);
+ await sandbox.provision(layers);
+ assert.equal(
+ readFileSync(join(sudoersDir, "qm-env"), "utf8"),
+ 'Defaults env_keep += "DEBIAN_FRONTEND GIT_TERMINAL_PROMPT http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy no_proxy NO_PROXY GIT_HTTP_PROXY_AUTHMETHOD"\n',
+ );
+ } finally {
+ process.env.PATH = path;
+ }
+});
diff --git a/test/support/fake-agent37.ts b/test/support/fake-agent37.ts
index 2c7e883e8..124464d9d 100644
--- a/test/support/fake-agent37.ts
+++ b/test/support/fake-agent37.ts
@@ -94,6 +94,7 @@ export function installFakeAgent37(): FakeAgent37 {
script
.replace(/\btimeout (?:-k \d+ )?\d+ /g, "")
.replace(/\/home\/node/g, m.home)
+ .replaceAll("/etc/sudoers.d", `${m.home}/.etc-sudoers.d`)
.replace(remapPath, (mm) => (mm.startsWith(m.home) ? mm : `${m.home}/tmp/`))
);
};
diff --git a/test/support/fake-e2b.ts b/test/support/fake-e2b.ts
index 4c0d5850a..1e5a1b506 100644
--- a/test/support/fake-e2b.ts
+++ b/test/support/fake-e2b.ts
@@ -67,6 +67,7 @@ export function installFakeE2b(fakeOpts: { info?: boolean } = {}): FakeE2b {
script
.replace(/\btimeout \d+ /g, "")
.replace(/\/home\/user/g, r.home)
+ .replaceAll("/etc/sudoers.d", `${r.home}/.etc-sudoers.d`)
.replace(remapPath, (mm) => (mm.startsWith(r.home) ? mm : `${r.home}/tmp/`))
);
};
diff --git a/test/support/fake-managed-agents.ts b/test/support/fake-managed-agents.ts
index 807d8a031..086e16b46 100644
--- a/test/support/fake-managed-agents.ts
+++ b/test/support/fake-managed-agents.ts
@@ -100,6 +100,7 @@ export function installFakeManagedAgents(): FakeManagedAgents {
script
.replace(/\btimeout \d+ /g, "")
.replace(GUEST_ROOT_PREFIX, r.guestRoot)
+ .replaceAll("/etc/sudoers.d", `${r.guestRoot}/.etc-sudoers.d`)
.replace(remapPath, (mm) => (mm.startsWith(r.guestRoot) ? mm : `${r.guestRoot}/tmp/`))
);
};
diff --git a/test/support/fake-modal.ts b/test/support/fake-modal.ts
index 768740bf4..a79695703 100644
--- a/test/support/fake-modal.ts
+++ b/test/support/fake-modal.ts
@@ -56,6 +56,7 @@ export function installFakeModal(opts: { native?: boolean } = {}): FakeModal {
script
.replace(/\btimeout \d+ /g, "")
.replace(/\/root(?![A-Za-z0-9_-])/g, r.home)
+ .replaceAll("/etc/sudoers.d", `${r.home}/.etc-sudoers.d`)
.replace(remapPath, (mm) => (mm.startsWith(r.home) ? mm : `${r.home}/tmp/`))
);
};
diff --git a/test/support/fake-porter.ts b/test/support/fake-porter.ts
index 7df4446b6..b11c57e4f 100644
--- a/test/support/fake-porter.ts
+++ b/test/support/fake-porter.ts
@@ -83,6 +83,7 @@ export function installFakePorter(opts: FakePorterOptions = {}): FakePorter {
let out = script
.replace(/\btimeout (?:-k \d+ )?\d+ /g, "")
.replace(remapTmp, `${b.tmp}/`)
+ .replaceAll("/etc/sudoers.d", `${b.home}/.etc-sudoers.d`)
.replace(pathRe(GUEST_HOME), b.home)
.replace(pathRe(GUEST_APP), b.app);
for (const [guest, dir] of Object.entries(b.mounts))
diff --git a/test/support/fake-smolmachines.ts b/test/support/fake-smolmachines.ts
index 2abf25bb0..612ce8181 100644
--- a/test/support/fake-smolmachines.ts
+++ b/test/support/fake-smolmachines.ts
@@ -105,6 +105,7 @@ export function installFakeSmolmachines(): FakeSmolmachines {
script
.replace(/\btimeout \d+ /g, "")
.replace(/\/root/g, m.home)
+ .replaceAll("/etc/sudoers.d", `${m.home}/.etc-sudoers.d`)
.replace(remapPath, (mm) => (mm.startsWith(m.home) ? mm : `${m.home}/tmp/`))
);
};
diff --git a/test/support/fake-sprites.ts b/test/support/fake-sprites.ts
index acf108399..609c36c85 100644
--- a/test/support/fake-sprites.ts
+++ b/test/support/fake-sprites.ts
@@ -213,6 +213,7 @@ export function installFakeSprites(origin = `https://fake-sprites-${++nextOrigin
.replace(/\/proc\/pressure\/io/g, `${home}/.proc-pressure-io`)
.replace(/\/proc\/loadavg/g, `${home}/.proc-loadavg`)
.replace(/\/usr\/local/g, `${home}/.usr-local`)
+ .replaceAll("/etc/sudoers.d", `${home}/.etc-sudoers.d`)
.replace(/\/home\/sprite/g, home)
.replace(remapPath, (m) => (m.startsWith(home) ? m : `${home}/tmp/`))
);
diff --git a/test/support/fake-superserve.ts b/test/support/fake-superserve.ts
index 01ac682a2..55b689d43 100644
--- a/test/support/fake-superserve.ts
+++ b/test/support/fake-superserve.ts
@@ -81,6 +81,7 @@ export function installFakeSuperserve(): FakeSuperserve {
const remap = (r: FakeRecord, script: string): string =>
script
.replace(/\btimeout (?:-k \d+ )?\d+ /g, "")
+ .replaceAll("/etc/sudoers.d", `${r.home}/.etc-sudoers.d`)
.replace(/(^|[^A-Za-z0-9._/-])\/tmp\//g, `$1${r.home}/tmp/`)
.replace(/(^|[^A-Za-z0-9._/-])\/root(?=\/|$|[^A-Za-z0-9._/-])/g, `$1${r.home}`);