Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: introduce a new flag disable-chromium-sandbox #186252

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,21 @@ bootstrap.enableASARSupport();
const args = parseCLIArgs();
// 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']) {
// Enable sandbox globally unless
// 1) disabled via command line using either
// `--no-sandbox` or `--disable-chromium-sandbox` argument.
// 2) argv.json contains `disable-chromium-sandbox: true`.
if (args['sandbox'] &&
!args['disable-chromium-sandbox'] &&
!argvConfig['disable-chromium-sandbox']) {
app.enableSandbox();
} else if (app.commandLine.hasSwitch('no-sandbox') &&
!app.commandLine.hasSwitch('disable-gpu-sandbox')) {
// Disable GPU sandbox whenever --no-sandbox is used.
app.commandLine.appendSwitch('disable-gpu-sandbox');
} else {
app.commandLine.appendSwitch('no-sandbox');
app.commandLine.appendSwitch('disable-gpu-sandbox');
}

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

// disable chromium sandbox
'disable-chromium-sandbox',

// override which password-store is used
'password-store'
];
Expand Down Expand Up @@ -238,9 +246,6 @@ 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 Expand Up @@ -480,6 +485,9 @@ function parseCLIArgs() {
'js-flags',
'crash-reporter-directory'
],
boolean: [
'disable-chromium-sandbox',
],
default: {
'sandbox': true
},
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/common/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface NativeParsedArgs {
'locate-shell-integration-path'?: string;
'profile'?: string;
'profile-temp'?: boolean;
'disable-chromium-sandbox'?: boolean;

'enable-coi'?: boolean;

Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/node/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'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.") },
'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.") },
'disable-gpu': { type: 'boolean', cat: 't', description: localize('disableGPU', "Disable GPU hardware acceleration.") },
'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.") },
'ms-enable-electron-run-as-node': { type: 'boolean', global: true },
'telemetry': { type: 'boolean', cat: 't', description: localize('telemetry', "Shows all telemetry events which VS code collects.") },

Expand Down