Skip to content

Commit 5f09f73

Browse files
committed
Include local username in controlPath hash to prevent cross-user collisions
On multi-user systems, different users connecting to the same remote would generate identical socket paths, causing permission errors. Now includes os.userInfo().username in the hash to ensure socket isolation per user. Addresses Codex review comment.
1 parent 27cd794 commit 5f09f73

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/runtime/sshConnectionPool.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,20 @@ describe("sshConnectionPool", () => {
113113
});
114114
});
115115
});
116+
117+
describe("username isolation", () => {
118+
test("controlPath includes local username to prevent cross-user collisions", () => {
119+
// This test verifies that os.userInfo().username is included in the hash
120+
// On multi-user systems, different users connecting to the same remote
121+
// would get different controlPaths, preventing permission errors
122+
const config: SSHRuntimeConfig = {
123+
host: "test.com",
124+
srcBaseDir: "/work",
125+
};
126+
const controlPath = getControlPath(config);
127+
128+
// The path should be deterministic for this user
129+
expect(controlPath).toBe(getControlPath(config));
130+
expect(controlPath).toMatch(/^\/tmp\/cmux-ssh-[a-f0-9]{12}$/);
131+
});
132+
});

0 commit comments

Comments
 (0)