提交 243ccb42 编写于 作者: J Joao Moreno

windows ipc handles should be scoped to user data dir

上级 91d66375
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册