14

I'm building an application with Electron and packaging with Electron Builder. When running electron, I want to pass this command line argument: --enable-mixed-sandbox.

Is it possible? How?

This:

 app.commandLine.appendSwitch('enable-mixed-sandbox')

wouldn't work due to:

Note that it is not enough to call app.commandLine.appendSwitch('--enable-sandbox'), as electron/node startup code runs after it is possible to make changes to chromium sandbox settings. The switch must be passed to electron on the command-line:

electron --enable-sandbox app.js

It is not possible to have the OS sandbox active only for some renderers, if --enable-sandbox is enabled, normal electron windows cannot be created.

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

3 Answers3

0

enable-mixed-sandbox is not a valid Electron command line flag. See here for all available command line flags for Electron.

-1

I got a response on that issue I raised and linked to in the comments:

app.enableMixedSandbox() // Experimental macOS Windows

See here for documentation.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
SwiftsNamesake
  • 1,540
  • 2
  • 11
  • 25
-1

another way of doing it, you can use spectron to start the app in debug mode. which allows you to pass any arguments you want.

const Application = require('spectron').Application

// Returns a promise that resolves to a Spectron Application once the app has loaded.
// Takes a Ava test. Makes some basic assertions to verify that the app loaded correctly.
function createApp (t) {
  return new Application({
    path: 'path/to/app',
    args: ['-r', '--enable-mixed-sandbox'],
    env: {NODE_ENV: 'test'},
    waitTimeout: 10e3
  })
}

https://github.com/electron/spectron#new-applicationoptions

Necmttn
  • 1,137
  • 1
  • 9
  • 17
  • 1
    How does that work with electron builder to distribute apps? I can pass whatever argument I want in dev mode, that's not the issue. The issue is the .exe generated by electron-builder. – Pablo Fernandez Aug 07 '17 at 09:34
  • well I don't think you can pass sandbox for bundled app because of security concerns. as electron mentioned in docs _Some bug in V8 engine may allow malicious code to access the renderer preload APIs, effectively granting full access to the system through the remote module._ check this [link](https://stackoverflow.com/a/34742370/6942552) as well might explain a bit more. – Necmttn Aug 07 '17 at 09:59