Skip to content

Commit

Permalink
feat: provide disable-chromium-sandbox runtime argument (microsoft#18…
Browse files Browse the repository at this point in the history
…6004)

* feat: provide disable-chromium-sandbox runtime argument

* chore: address review feedback

* chore: remove relaunch prompt
  • Loading branch information
deepak1556 authored and gjsjohnmurray committed Jun 26, 2023
1 parent 17f2351 commit 9d48aa5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ const portable = bootstrapNode.configurePortable(product);
// Enable ASAR support
bootstrap.enableASARSupport();

// Enable sandbox globally unless disabled via `--no-sandbox` argument
const args = parseCLIArgs();
if (args['sandbox']) {
// Configure static command line arguments
const argvConfig = configureCommandlineSwitchesSync(args);
// Enable sandbox globally unless disabled via `--no-sandbox` argument
// or if `disable-chromium-sandbox: true` is set in argv.json.
if (args['sandbox'] && !argvConfig['disable-chromium-sandbox']) {
app.enableSandbox();
}

Expand All @@ -52,9 +55,6 @@ app.setPath('userData', userDataPath);
// Resolve code cache path
const codeCachePath = getCodeCachePath();

// Configure static command line arguments
const argvConfig = configureCommandlineSwitchesSync(args);

// Disable default menu (https://github.com/electron/electron/issues/35512)
Menu.setApplicationMenu(null);

Expand Down Expand Up @@ -190,7 +190,10 @@ function configureCommandlineSwitchesSync(cliArgs) {
'disable-hardware-acceleration',

// override for the color profile to use
'force-color-profile'
'force-color-profile',

// disable chromium sandbox
'disable-chromium-sandbox',
];

if (process.platform === 'linux') {
Expand Down Expand Up @@ -228,6 +231,9 @@ function configureCommandlineSwitchesSync(cliArgs) {
else if (argvValue === true || argvValue === 'true') {
if (argvKey === 'disable-hardware-acceleration') {
app.disableHardwareAcceleration(); // needs to be called explicitly
} else if (argvKey === 'disable-chromium-sandbox') {
app.commandLine.appendSwitch('no-sandbox');
app.commandLine.appendSwitch('disable-gpu-sandbox');
} else {
app.commandLine.appendSwitch(argvKey);
}
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/electron-sandbox/desktop.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ import { applicationConfigurationNodeBase } from 'vs/workbench/common/configurat
'log-level': {
type: ['string', 'array'],
description: localize('argv.logLevel', "Log level to use. Default is 'info'. Allowed values are 'error', 'warn', 'info', 'debug', 'trace', 'off'.")
},
'disable-chromium-sandbox': {
type: 'boolean',
description: localize('argv.disableChromiumSandbox', "Disables the Chromium sandbox. This is useful when running VS Code as elevated on Linux and running under Applocker on Windows.")
}
}
};
Expand Down

0 comments on commit 9d48aa5

Please sign in to comment.