electron-99: added attributes to control sandboxing

This commit is contained in:
Vishwas Shashidhar 2017-07-14 12:57:38 +05:30
parent c6f84adc44
commit 83fb71cfb2
4 changed files with 17 additions and 10 deletions

View File

@ -45,10 +45,10 @@ fi
rm -f $tempFilePath rm -f $tempFilePath
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app ## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS # EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin # mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin
cat > $EXEC_PATH/Symphony << EOT # cat > $EXEC_PATH/Symphony << EOT
#!/bin/sh # #!/bin/sh
exec "\${0%/*}/Symphony-bin" --enable-sandbox \$@ # exec "\${0%/*}/Symphony-bin" --enable-sandbox \$@
EOT # EOT
chmod 755 $EXEC_PATH/Symphony # chmod 755 $EXEC_PATH/Symphony

View File

@ -48,6 +48,8 @@ let externalDisplay;
// user selected display id for notification // user selected display id for notification
let displayId; let displayId;
let sandboxed = false;
let config = { let config = {
// corner to put notifications // corner to put notifications
// upper-right, upper-left, lower-right, lower-left // upper-right, upper-left, lower-right, lower-left
@ -131,7 +133,7 @@ let config = {
acceptFirstMouse: true, acceptFirstMouse: true,
webPreferences: { webPreferences: {
preload: path.join(__dirname, 'electron-notify-preload.js'), preload: path.join(__dirname, 'electron-notify-preload.js'),
sandbox: !isNodeEnv, sandbox: sandboxed,
nodeIntegration: isNodeEnv nodeIntegration: isNodeEnv
} }
} }

View File

@ -17,6 +17,7 @@ let configurationWindow;
let screens; let screens;
let position; let position;
let display; let display;
let sandboxed = false;
let windowConfig = { let windowConfig = {
width: 460, width: 460,
@ -27,7 +28,7 @@ let windowConfig = {
resizable: false, resizable: false,
webPreferences: { webPreferences: {
preload: path.join(__dirname, 'configure-notification-position-preload.js'), preload: path.join(__dirname, 'configure-notification-position-preload.js'),
sandbox: true, sandbox: sandboxed,
nodeIntegration: false nodeIntegration: false
} }
}; };

View File

@ -37,6 +37,7 @@ let boundsChangeWindow;
let alwaysOnTop = false; let alwaysOnTop = false;
let position = 'lower-right'; let position = 'lower-right';
let display; let display;
let sandboxed = false;
// note: this file is built using browserify in prebuild step. // note: this file is built using browserify in prebuild step.
const preloadMainScript = path.join(__dirname, 'preload/_preloadMain.js'); const preloadMainScript = path.join(__dirname, 'preload/_preloadMain.js');
@ -81,7 +82,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
minHeight: MIN_HEIGHT, minHeight: MIN_HEIGHT,
alwaysOnTop: false, alwaysOnTop: false,
webPreferences: { webPreferences: {
sandbox: !isNodeEnv, sandbox: sandboxed,
nodeIntegration: isNodeEnv, nodeIntegration: isNodeEnv,
preload: preloadMainScript, preload: preloadMainScript,
} }
@ -212,6 +213,9 @@ function doCreateMainWindow(initialUrl, initialBounds) {
// bug in electron is preventing this from working in sandboxed evt... // bug in electron is preventing this from working in sandboxed evt...
// https://github.com/electron/electron/issues/8841 // https://github.com/electron/electron/issues/8841
mainWindow.webContents.on('will-navigate', function(event, willNavUrl) { mainWindow.webContents.on('will-navigate', function(event, willNavUrl) {
if (!sandboxed) {
return;
}
event.preventDefault(); event.preventDefault();
openUrlInDefaultBrower(willNavUrl); openUrlInDefaultBrower(willNavUrl);
}); });