From c82ac047c4f43f738d212c3d6e600180475543d0 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 7 Apr 2016 22:14:12 -0700 Subject: [PATCH] Reland: Disable welcome page when user is root Ideally this is a temporary fix for gettingStarted and can be removed once the freeze is fixed in electron. Fixes #3068 Fixes #5067 --- src/vs/base/common/platform.ts | 4 ++++ .../electron-browser/electronGettingStarted.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/vs/base/common/platform.ts b/src/vs/base/common/platform.ts index ed87f690a68b7..09933a26b5cd8 100644 --- a/src/vs/base/common/platform.ts +++ b/src/vs/base/common/platform.ts @@ -9,6 +9,7 @@ let _isWindows = false; let _isMacintosh = false; let _isLinux = false; +let _isRootUser = false; let _isNative = false; let _isWeb = false; let _isQunit = false; @@ -23,6 +24,7 @@ interface NLSConfig { interface INodeProcess { platform: string; env: { [key: string]: string; }; + getuid(): number; } declare let process: INodeProcess; declare let global: any; @@ -39,6 +41,7 @@ if (typeof process === 'object') { _isWindows = (process.platform === 'win32'); _isMacintosh = (process.platform === 'darwin'); _isLinux = (process.platform === 'linux'); + _isRootUser = !_isWindows && (process.getuid() === 0); let vscode_nls_config = process.env['VSCODE_NLS_CONFIG']; if (vscode_nls_config) { try { @@ -83,6 +86,7 @@ if (_isNative) { export const isWindows = _isWindows; export const isMacintosh = _isMacintosh; export const isLinux = _isLinux; +export const isRootUser = _isRootUser; export const isNative = _isNative; export const isWeb = _isWeb; export const isQunit = _isQunit; diff --git a/src/vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.ts b/src/vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.ts index 48c69ab266779..90d847fa3e480 100644 --- a/src/vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.ts +++ b/src/vs/workbench/parts/gettingStarted/electron-browser/electronGettingStarted.ts @@ -6,12 +6,18 @@ import {IWorkbenchContribution} from 'vs/workbench/common/contributions'; import {AbstractGettingStarted} from 'vs/workbench/parts/gettingStarted/common/abstractGettingStarted'; +import * as platform from 'vs/base/common/platform'; import { shell } from 'electron'; export class ElectronGettingStarted extends AbstractGettingStarted implements IWorkbenchContribution { protected openExternal(url: string) { + // Don't open the welcome page as the root user on Linux, this is due to a bug with xdg-open + // which recommends against running itself as root. + if (platform.isLinux && platform.isRootUser) { + return; + } shell.openExternal(url); }