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
## 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
mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin
cat > $EXEC_PATH/Symphony << EOT
#!/bin/sh
exec "\${0%/*}/Symphony-bin" --enable-sandbox \$@
EOT
chmod 755 $EXEC_PATH/Symphony
# EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
# mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin
# cat > $EXEC_PATH/Symphony << EOT
# #!/bin/sh
# exec "\${0%/*}/Symphony-bin" --enable-sandbox \$@
# EOT
# chmod 755 $EXEC_PATH/Symphony

View File

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

View File

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

View File

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