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
2 changes: 1 addition & 1 deletion agents/hermes/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ cmdline_is_hermes_gateway() {
local cmdline=" $1 "

case "$cmdline" in
*"/hermes gateway run "* | *" hermes gateway run "*) return 0 ;;
*"/hermes gateway run "* | *" hermes gateway run "* | *"/hermes.real gateway run "* | *" hermes.real gateway run "*) return 0 ;;
esac
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test-hermes-root-entrypoint-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ assert_runtime_layout() {
assert_gateway_process() {
local container="$1"
assert_container_sh "$container" "Hermes gateway process is not running as gateway user" \
"ps -eo user=,args= | awk '\$1 == \"gateway\" && index(\$0, \"hermes gateway run\") { found = 1 } END { exit found ? 0 : 1 }'"
"ps -eo user=,args= | awk '\$1 == \"gateway\" && (index(\$0, \"hermes gateway run\") || index(\$0, \"hermes.real gateway run\")) { found = 1 } END { exit found ? 0 : 1 }'"
assert_container_sh "$container" "start log does not show gateway privilege separation" \
"grep -F \"hermes gateway launched as 'gateway' user\" /tmp/nemoclaw-start.log"
}
Expand Down
22 changes: 21 additions & 1 deletion test/hermes-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ function lstatIfPresent(entry: string): fs.Stats | null {

function runHermesGatewayRuntimeCleanup(opts: {
liveGateway?: boolean;
liveGatewayArgv?: string[];
orphanSocat?: boolean;
orphanDashboardSocat?: boolean;
staleLock?: boolean;
Expand Down Expand Up @@ -430,7 +431,11 @@ function runHermesGatewayRuntimeCleanup(opts: {
if (opts.stalePid !== false) fs.writeFileSync(runtimePid, "999999\n");
if (opts.staleLock !== false) fs.writeFileSync(runtimeLock, "stale lock");
if (opts.liveGateway) {
writeFakeProcCmdline(procRoot, 123, ["/usr/local/bin/hermes", "gateway", "run"]);
writeFakeProcCmdline(
procRoot,
123,
opts.liveGatewayArgv ?? ["/usr/local/bin/hermes", "gateway", "run"],
);
}
if (opts.orphanSocat) {
writeFakeProcCmdline(procRoot, 456, [
Expand Down Expand Up @@ -1068,6 +1073,21 @@ describe("agents/hermes/start.sh gateway runtime cleanup", () => {
expect(run.killLog).toBe("");
expect(run.result.stderr).toContain("Existing Hermes gateway process detected");
});

it("preserves Hermes runtime state when the wrapped gateway execs hermes.real", () => {
const run = runHermesGatewayRuntimeCleanup({
liveGateway: true,
liveGatewayArgv: ["/usr/local/bin/hermes.real", "gateway", "run"],
orphanSocat: true,
});

expect(run.result.status).toBe(0);
expect(run.runtimePidExists).toBe(true);
expect(run.runtimeLockExists).toBe(true);
expect(run.legacyPidIsSymlink).toBe(true);
expect(run.killLog).toBe("");
expect(run.result.stderr).toContain("Existing Hermes gateway process detected");
});
});

function runShieldsUpRuntimeEnv(opts: { locked: boolean; presetValue?: string }) {
Expand Down
Loading