Skip to content

Commit 35ddc72

Browse files
authored
chore: introduce a new flag disable-chromium-sandbox (microsoft#186252)
1 parent 45b31e9 commit 35ddc72

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/main.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,21 @@ bootstrap.enableASARSupport();
3636
const args = parseCLIArgs();
3737
// Configure static command line arguments
3838
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']) {
39+
// Enable sandbox globally unless
40+
// 1) disabled via command line using either
41+
// `--no-sandbox` or `--disable-chromium-sandbox` argument.
42+
// 2) argv.json contains `disable-chromium-sandbox: true`.
43+
if (args['sandbox'] &&
44+
!args['disable-chromium-sandbox'] &&
45+
!argvConfig['disable-chromium-sandbox']) {
4246
app.enableSandbox();
47+
} else if (app.commandLine.hasSwitch('no-sandbox') &&
48+
!app.commandLine.hasSwitch('disable-gpu-sandbox')) {
49+
// Disable GPU sandbox whenever --no-sandbox is used.
50+
app.commandLine.appendSwitch('disable-gpu-sandbox');
51+
} else {
52+
app.commandLine.appendSwitch('no-sandbox');
53+
app.commandLine.appendSwitch('disable-gpu-sandbox');
4354
}
4455

4556
// Set userData path before app 'ready' event
@@ -192,9 +203,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
192203
// override for the color profile to use
193204
'force-color-profile',
194205

195-
// disable chromium sandbox
196-
'disable-chromium-sandbox',
197-
198206
// override which password-store is used
199207
'password-store'
200208
];
@@ -238,9 +246,6 @@ function configureCommandlineSwitchesSync(cliArgs) {
238246
else if (argvValue === true || argvValue === 'true') {
239247
if (argvKey === 'disable-hardware-acceleration') {
240248
app.disableHardwareAcceleration(); // needs to be called explicitly
241-
} else if (argvKey === 'disable-chromium-sandbox') {
242-
app.commandLine.appendSwitch('no-sandbox');
243-
app.commandLine.appendSwitch('disable-gpu-sandbox');
244249
} else {
245250
app.commandLine.appendSwitch(argvKey);
246251
}
@@ -480,6 +485,9 @@ function parseCLIArgs() {
480485
'js-flags',
481486
'crash-reporter-directory'
482487
],
488+
boolean: [
489+
'disable-chromium-sandbox',
490+
],
483491
default: {
484492
'sandbox': true
485493
},

src/vs/platform/environment/common/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export interface NativeParsedArgs {
109109
'locate-shell-integration-path'?: string;
110110
'profile'?: string;
111111
'profile-temp'?: boolean;
112+
'disable-chromium-sandbox'?: boolean;
112113

113114
'enable-coi'?: boolean;
114115

src/vs/platform/environment/node/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
109109
'inspect-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugPluginHost'], args: 'port', cat: 't', description: localize('inspect-extensions', "Allow debugging and profiling of extensions. Check the developer tools for the connection URI.") },
110110
'inspect-brk-extensions': { type: 'string', allowEmptyValue: true, deprecates: ['debugBrkPluginHost'], args: 'port', cat: 't', description: localize('inspect-brk-extensions', "Allow debugging and profiling of extensions with the extension host being paused after start. Check the developer tools for the connection URI.") },
111111
'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
112+
'disable-chromium-sandbox': { type: 'boolean', cat: 't', description: localize('disableChromiumSandbox', "Use this option only when there is requirement to launch the application as sudo user on Linux or when running as an elevated user in an applocker environment on Windows.") },
112113
'ms-enable-electron-run-as-node': { type: 'boolean', global: true },
113114
'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },
114115

0 commit comments

Comments
 (0)