Skip to content

Commit 6616247

Browse files
committed
Apply to session files
1 parent 759caf1 commit 6616247

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/session.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export async function writeSessionFile(pid: string, pipePath: string) {
285285
await fs.ensureDir(sessionsDir);
286286
const filePath = path.join(sessionsDir, `${pid}.json`);
287287
await fs.writeJson(filePath, { pipe: pipePath });
288+
await setOwnerOnlyPermissions(filePath);
288289
}
289290

290291
async function updateActiveTerminalFiles(pipePath: string) {

src/test/suite/session.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ suite('Session Communication', () => {
238238
assert.strictEqual(pipeStat.mode & 0o777, 0o600, 'socket file should be owner-only');
239239
}
240240

241+
const sessionFilePid = `perm-test-${process.pid}`;
242+
await session.writeSessionFile(sessionFilePid, pipePath ?? '');
243+
const sessionFilePath = path.join(process.env.HOME ?? '', '.vscode-R', 'sessions', `${sessionFilePid}.json`);
244+
const sessionFileStat = await fs.stat(sessionFilePath);
245+
assert.strictEqual(sessionFileStat.mode & 0o777, 0o600, 'session handoff file should be owner-only');
246+
await fs.remove(sessionFilePath);
247+
241248
await session.shutdownSessionWatcher();
242249
}).timeout(15000);
243250
});

0 commit comments

Comments
 (0)