Skip to content

Commit 7f9a404

Browse files
authored
feat: provide disable-chromium-sandbox runtime argument (microsoft#186004)
* feat: provide disable-chromium-sandbox runtime argument * chore: address review feedback * chore: remove relaunch prompt
1 parent b4952d1 commit 7f9a404

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/main.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ const portable = bootstrapNode.configurePortable(product);
3333
// Enable ASAR support
3434
bootstrap.enableASARSupport();
3535

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

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

55-
// Configure static command line arguments
56-
const argvConfig = configureCommandlineSwitchesSync(args);
57-
5858
// Disable default menu (https://github.com/electron/electron/issues/35512)
5959
Menu.setApplicationMenu(null);
6060

@@ -190,7 +190,10 @@ function configureCommandlineSwitchesSync(cliArgs) {
190190
'disable-hardware-acceleration',
191191

192192
// override for the color profile to use
193-
'force-color-profile'
193+
'force-color-profile',
194+
195+
// disable chromium sandbox
196+
'disable-chromium-sandbox',
194197
];
195198

196199
if (process.platform === 'linux') {
@@ -228,6 +231,9 @@ function configureCommandlineSwitchesSync(cliArgs) {
228231
else if (argvValue === true || argvValue === 'true') {
229232
if (argvKey === 'disable-hardware-acceleration') {
230233
app.disableHardwareAcceleration(); // needs to be called explicitly
234+
} else if (argvKey === 'disable-chromium-sandbox') {
235+
app.commandLine.appendSwitch('no-sandbox');
236+
app.commandLine.appendSwitch('disable-gpu-sandbox');
231237
} else {
232238
app.commandLine.appendSwitch(argvKey);
233239
}

src/vs/workbench/electron-sandbox/desktop.contribution.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ import { applicationConfigurationNodeBase } from 'vs/workbench/common/configurat
345345
'log-level': {
346346
type: ['string', 'array'],
347347
description: localize('argv.logLevel', "Log level to use. Default is 'info'. Allowed values are 'error', 'warn', 'info', 'debug', 'trace', 'off'.")
348+
},
349+
'disable-chromium-sandbox': {
350+
type: 'boolean',
351+
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.")
348352
}
349353
}
350354
};

0 commit comments

Comments
 (0)