From 4f95907b19c4ac0f9553007fd7fc7043f1ebb960 Mon Sep 17 00:00:00 2001 From: Robo Date: Wed, 14 Jun 2023 08:09:48 +0900 Subject: [PATCH] fix: disable app sandbox when --no-sandbox is present (#184913) * fix: disable app sandbox when --no-sandbox is present (#184897) * fix: loading minimist in packaged builds --- src/main.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index d986fee6f6dc1..5b3bcf8b9abdf 100644 --- a/src/main.js +++ b/src/main.js @@ -27,17 +27,19 @@ const { getUNCHost, addUNCHostToAllowlist } = require('./vs/base/node/unc'); const product = require('../product.json'); const { app, protocol, crashReporter, Menu } = require('electron'); -// Enable sandbox globally -app.enableSandbox(); - // Enable portable support const portable = bootstrapNode.configurePortable(product); // Enable ASAR support bootstrap.enableASARSupport(); -// Set userData path before app 'ready' event +// Enable sandbox globally unless disabled via `--no-sandbox` argument const args = parseCLIArgs(); +if (args['sandbox']) { + app.enableSandbox(); +} + +// Set userData path before app 'ready' event const userDataPath = getUserDataPath(args, product.nameShort ?? 'code-oss-dev'); if (process.platform === 'win32') { const userDataUNCHost = getUNCHost(userDataPath); @@ -464,7 +466,13 @@ function parseCLIArgs() { 'locale', 'js-flags', 'crash-reporter-directory' - ] + ], + default: { + 'sandbox': true + }, + alias: { + 'no-sandbox': 'sandbox' + } }); }