Skip to content

Commit

Permalink
Reland: Disable welcome page when user is root
Browse files Browse the repository at this point in the history
Ideally this is a temporary fix for gettingStarted and can be removed once the
freeze is fixed in electron.

Fixes #3068
Fixes #5067
  • Loading branch information
Tyriar committed Apr 8, 2016
1 parent 3e16b9b commit c82ac04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vs/base/common/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +24,7 @@ interface NLSConfig {
interface INodeProcess {
platform: string;
env: { [key: string]: string; };
getuid(): number;
}
declare let process: INodeProcess;
declare let global: any;
Expand All @@ -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);

This comment has been minimized.

Copy link
@bpasero

bpasero Apr 8, 2016

Member

@Tyriar we cannot reference node APIs from vs/base/common. Please review https://github.com/Microsoft/vscode/wiki/Code-Organization#layers !

This comment has been minimized.

Copy link
@Tyriar

Tyriar Apr 8, 2016

Author Member

Isn't process.platform a node API on the above line?

This comment has been minimized.

Copy link
@Tyriar

Tyriar Apr 8, 2016

Author Member

This section is gated by this so isn't it safe?

// OS detection
if (typeof process === 'object') {

Seems like the logical place to put something pulled from process.

This comment has been minimized.

Copy link
@bpasero

bpasero Apr 8, 2016

Member

Right, thats probably the only place where we do this kind of check. I am not encouraging to put more node stuff into common but in that case it is probably ok.

This comment has been minimized.

Copy link
@Tyriar

Tyriar Apr 8, 2016

Author Member

Understood, I have a pretty good understanding of the layers now after messing with wrapping shell.openExternal in IWindowService (and then backtracking and upstreaming).

This comment has been minimized.

Copy link
@bpasero

bpasero Apr 8, 2016

Member

Great :) 👍

let vscode_nls_config = process.env['VSCODE_NLS_CONFIG'];
if (vscode_nls_config) {
try {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c82ac04

Please sign in to comment.