Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/lib/onboard/docker-driver-gateway-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ function readTextFileIfPresent(filePath: string): string {
}
}

export function writeDockerGatewayDebEnvOverride(
getOverride: () => Record<string, string>,
opts: Parameters<typeof hasOpenShellGatewayUserService>[0] = {},
): boolean {
if (!hasOpenShellGatewayUserService(opts)) return false;
function writeDockerGatewayDebEnvOverrideFile(getOverride: () => Record<string, string>): void {
const override = getOverride();
const envDir = path.join(os.homedir(), ".config", "openshell");
const envFile = path.join(envDir, "gateway.env");
Expand All @@ -160,6 +156,14 @@ export function writeDockerGatewayDebEnvOverride(
mode: 0o600,
});
fs.chmodSync(envFile, 0o600);
}

export function writeDockerGatewayDebEnvOverride(
getOverride: () => Record<string, string>,
opts: Parameters<typeof hasOpenShellGatewayUserService>[0] = {},
): boolean {
if (!hasOpenShellGatewayUserService(opts)) return false;
writeDockerGatewayDebEnvOverrideFile(getOverride);
return true;
}

Expand All @@ -179,6 +183,6 @@ export function startPackageManagedDockerDriverGatewayWithEnvOverride({
return startPackageManagedDockerDriverGateway({
...options,
prepareOpenShellGatewayUserServiceEnv: () =>
writeDockerGatewayDebEnvOverrideOrThrow(() => gatewayEnv),
writeDockerGatewayDebEnvOverrideFile(() => gatewayEnv),
});
}
5 changes: 4 additions & 1 deletion test/cli/sandbox-mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ describe("CLI dispatch", () => {

for (const action of ["add", "remove", "start", "stop"]) {
const missingChannel = runWithEnv(`alpha channels ${action} 2>&1`, { HOME: home });
expect(missingChannel.code).toBe(PARSER_EXIT_CODE);
expect(
missingChannel.code,
`alpha channels ${action} exited ${missingChannel.code} with output:\n${missingChannel.out}`,
).toBe(PARSER_EXIT_CODE);
expect(missingChannel.out).toContain("Missing 1 required arg:");
expect(missingChannel.out).toContain("channel Messaging channel");
expect(missingChannel.out).toContain("USAGE");
Expand Down
12 changes: 12 additions & 0 deletions test/hermes-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,25 @@ function runHermesGatewayRuntimeCleanup(opts: {
"TCP:127.0.0.1:19119",
]);
}
fs.writeFileSync(
path.join(tmpDir, "sitecustomize.py"),
[
"import os",
"",
"# Keep the Python helper aligned with the shell fixture's mocked id -u.",
"os.geteuid = lambda: 1000",
"",
].join("\n"),
);

const src = fs.readFileSync(START_SCRIPT, "utf-8");
fs.writeFileSync(
scriptPath,
[
"#!/usr/bin/env bash",
"set -euo pipefail",
`PYTHONPATH=${shellQuote(tmpDir)}`,
"export PYTHONPATH",
extractShellFunctionFromSource(src, "cmdline_is_hermes_gateway"),
extractShellFunctionFromSource(src, "has_live_hermes_gateway"),
extractShellFunctionFromSource(src, "cleanup_orphan_socat_forwarders"),
Expand Down
Loading