Skip to content

Commit 02ec02e

Browse files
authored
fix: disable app sandbox when --no-sandbox is present (microsoft#184897)
1 parent 46b43d1 commit 02ec02e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ const { getUNCHost, addUNCHostToAllowlist } = require('./vs/base/node/unc');
2727
const product = require('../product.json');
2828
const { app, protocol, crashReporter, Menu } = require('electron');
2929

30-
// Enable sandbox globally
31-
app.enableSandbox();
30+
// Enable sandbox globally unless disabled via `--no-sandbox` argument
31+
const args = parseCLIArgs();
32+
if (args['sandbox']) {
33+
app.enableSandbox();
34+
}
3235

3336
// Enable portable support
3437
const portable = bootstrapNode.configurePortable(product);
@@ -37,7 +40,6 @@ const portable = bootstrapNode.configurePortable(product);
3740
bootstrap.enableASARSupport();
3841

3942
// Set userData path before app 'ready' event
40-
const args = parseCLIArgs();
4143
const userDataPath = getUserDataPath(args, product.nameShort ?? 'code-oss-dev');
4244
if (process.platform === 'win32') {
4345
const userDataUNCHost = getUNCHost(userDataPath);
@@ -464,7 +466,13 @@ function parseCLIArgs() {
464466
'locale',
465467
'js-flags',
466468
'crash-reporter-directory'
467-
]
469+
],
470+
default: {
471+
'sandbox': true
472+
},
473+
alias: {
474+
'no-sandbox': 'sandbox'
475+
}
468476
});
469477
}
470478

0 commit comments

Comments
 (0)