From 243ccb42de6c97fca0fa351be61dffc43fb3c4fb Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Mon, 25 Sep 2017 17:10:52 +0200 Subject: [PATCH] windows ipc handles should be scoped to user data dir --- .../environment/node/environmentService.ts | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index f073e0fce56..0270370c755 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -15,38 +15,18 @@ import { memoize } from 'vs/base/common/decorators'; import pkg from 'vs/platform/node/package'; import product from 'vs/platform/node/product'; -function getUniqueUserId(): string { - let username: string; - if (process.platform === 'win32') { - username = process.env.USERNAME; - } else { - username = process.env.USER; - } - - if (!username) { - return ''; // fail gracefully if there is no user name - } - - // use sha256 to ensure the userid value can be used in filenames and are unique - return crypto.createHash('sha256').update(username).digest('hex').substr(0, 6); -} - function getNixIPCHandle(userDataPath: string, type: string): string { return path.join(userDataPath, `${pkg.version}-${type}.sock`); } -function getWin32IPCHandle(type: string): string { - // Support to run VS Code multiple times as different user - // by making the socket unique over the logged in user - const userId = getUniqueUserId(); - const name = product.applicationName + (userId ? `-${userId}` : ''); - - return `\\\\.\\pipe\\${name}-${pkg.version}-${type}-sock`; +function getWin32IPCHandle(userDataPath: string, type: string): string { + const scope = crypto.createHash('md5').update(userDataPath).digest('hex'); + return `\\\\.\\pipe\\${scope}-${pkg.version}-${type}-sock`; } function getIPCHandle(userDataPath: string, type: string): string { if (process.platform === 'win32') { - return getWin32IPCHandle(type); + return getWin32IPCHandle(userDataPath, type); } else { return getNixIPCHandle(userDataPath, type); }