diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index f073e0fce56d701e4031c46b619445b560060dc0..0270370c755dc5dcaea972a895f6056b3588a3ae 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); }