Skip to content

Commit

Permalink
tools: add macosx-firwall script to avoid popups
Browse files Browse the repository at this point in the history
Currently, there are a number of popups that get displayed when running
the tests asking to accept incoming network connections. Rules can be
added manually to the socket firewall on Mac OS X but getting this right
might not be obvious and quite a lot of time can be wasted trying to get
the rules right. This script hopes to simplify things a little so that
it can be re-run when needed.

The script should be runnable from both the projects root directory and
from the tools directory, for example:
$ sudo ./tools/macosx-firewall.sh

Fixes: nodejs#8911
  • Loading branch information
danbev committed Dec 4, 2016
1 parent 9dcf07a commit 7a5201d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ On OS X, you will also need:
* You also need to install the `Command Line Tools` via Xcode. You can find
this under the menu `Xcode -> Preferences -> Downloads`
* This step will install `gcc` and the related toolchain containing `make`
* You may want to setup [firewall rules](tools/macosx-firewall.sh) to avoid popups asking to accept incoming network connections when running tests.

On FreeBSD and OpenBSD, you may also need:
* libexecinfo
Expand Down
35 changes: 35 additions & 0 deletions tools/macosx-firewall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Script that adds rules to Mac OS X Socket Firewall to avoid
# popups asking to accept incoming network connections when
# running tests.
SFW="/usr/libexec/ApplicationFirewall/socketfilterfw"
TOOLSDIR="`dirname \"$0\"`"
TOOLSDIR="`( cd \"$TOOLSDIR\" && pwd) `"
ROOTDIR="`( cd \"$TOOLSDIR/..\" && pwd) `"
OUTDIR=$TOOLSDIR/../out
OUTDIR="`( cd \"$OUTDIR\" && pwd) `"
NODE_RELEASE=$OUTDIR/Release/node
NODE_DEBUG=$OUTDIR/Debug/node
NODE_LINK=$ROOTDIR/node

if [ -f $SFW ];
then
# Duplicating these commands on purpose as the symbolic link node might be
# linked to either out/Debug/node or out/Release/node depending on the
# BUILDTYPE.
$SFW --remove $NODE_DEBUG
$SFW --remove $NODE_DEBUG
$SFW --remove $NODE_RELEASE
$SFW --remove $NODE_RELEASE
$SFW --remove $NODE_LINK

$SFW --add $NODE_DEBUG
$SFW --add $NODE_RELEASE
$SFW --add $NODE_LINK

$SFW --unblock $NODE_DEBUG
$SFW --unblock $NODE_RELEASE
$SFW --unblock $NODE_LINK
else
echo "SocketFirewall not found in location: $SFW"
fi

0 comments on commit 7a5201d

Please sign in to comment.