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

feat: provide disable-chromium-sandbox runtime argument #186004

Merged
merged 3 commits into from
Jun 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading