From 7e752a2e1a915879b25fa79c79949059e4a9e1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Thu, 9 Jun 2022 09:24:56 +0200 Subject: [PATCH 1/2] Use childProcess.spawn instead of executeFile for running electron --- src/auth/resolvers/OnDemand/OnDemand.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/auth/resolvers/OnDemand/OnDemand.ts b/src/auth/resolvers/OnDemand/OnDemand.ts index c186abc..cd4e412 100644 --- a/src/auth/resolvers/OnDemand/OnDemand.ts +++ b/src/auth/resolvers/OnDemand/OnDemand.ts @@ -99,9 +99,16 @@ export class OnDemand implements IAuthResolver { private saveAuthData(dataPath: string): ICookie[] { const electronExecutable = this._authOptions.electron || 'electron'; - const isWindows = (process.platform.lastIndexOf('win') === 0); - const options: any = isWindows ? { shell: true } : undefined; - const output = childProcess.execFileSync(electronExecutable, [path.join(__dirname, 'electron/main.js'), '--', this._siteUrl, this._authOptions.force.toString()], options).toString(); + const electronProc = childProcess.spawnSync( + electronExecutable, + [ + path.join(__dirname, 'electron/main.js'), + '--', + this._siteUrl, + this._authOptions.force === true ? 'true' : 'false' + ] + ); + const output = electronProc.stdout.toString(); const cookieRegex = /#\{([\s\S]+?)\}#/gm; const cookieData = cookieRegex.exec(output); From ad972bedf2720832619772d65d2b47263f7df7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Thu, 9 Jun 2022 10:06:51 +0200 Subject: [PATCH 2/2] Add electron switch `no-sandbox`, addressing https://github.com/electron/electron/issues/32074 --- src/auth/resolvers/ondemand/electron/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/auth/resolvers/ondemand/electron/main.js b/src/auth/resolvers/ondemand/electron/main.js index 51b927f..f92093d 100644 --- a/src/auth/resolvers/ondemand/electron/main.js +++ b/src/auth/resolvers/ondemand/electron/main.js @@ -4,6 +4,7 @@ const process = require('process'); // Module to control application life. const app = electron.app; app.commandLine.appendSwitch('ignore-certificate-errors'); +app.commandLine.appendSwitch('no-sandbox'); // Module to create native browser window. const BrowserWindow = electron.BrowserWindow;