Skip to content

Commit cc5bd9a

Browse files
danbevFishrock123
authored andcommitted
tools: add macosx-firwall script to avoid popups
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: #8911 PR-URL: #10114 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3a460d5 commit cc5bd9a

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

BUILDING.md

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ On OS X, you will also need:
2424
this under the menu `Xcode -> Preferences -> Downloads`
2525
* This step will install `gcc` and the related toolchain containing `make`
2626

27+
* You may want to setup [firewall rules](tools/macosx-firewall.sh) to avoid
28+
popups asking to accept incoming network connections when running tests:
29+
30+
```console
31+
$ sudo ./tools/macosx-firewall.sh
32+
```
33+
Running this script will add rules for the executable `node` in the out
34+
directory and the symbolic `node` link in the projects root directory.
35+
2736
On FreeBSD and OpenBSD, you may also need:
2837
* libexecinfo
2938

tools/macosx-firewall.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# Script that adds rules to Mac OS X Socket Firewall to avoid
3+
# popups asking to accept incoming network connections when
4+
# running tests.
5+
SFW="/usr/libexec/ApplicationFirewall/socketfilterfw"
6+
TOOLSDIR="`dirname \"$0\"`"
7+
TOOLSDIR="`( cd \"$TOOLSDIR\" && pwd) `"
8+
ROOTDIR="`( cd \"$TOOLSDIR/..\" && pwd) `"
9+
OUTDIR="$TOOLSDIR/../out"
10+
# Using cd and pwd here so that the path used for socketfilterfw does not
11+
# contain a '..', which seems to cause the rules to be incorrectly added
12+
# and they are not removed when this script is re-run. Instead the new
13+
# rules are simply appended. By using pwd we can get the full path
14+
# without '..' and things work as expected.
15+
OUTDIR="`( cd \"$OUTDIR\" && pwd) `"
16+
NODE_RELEASE="$OUTDIR/Release/node"
17+
NODE_DEBUG="$OUTDIR/Debug/node"
18+
NODE_LINK="$ROOTDIR/node"
19+
CCTEST_RELEASE="$OUTDIR/Release/cctest"
20+
CCTEST_DEBUG="$OUTDIR/Debug/cctest"
21+
22+
if [ -f $SFW ];
23+
then
24+
# Duplicating these commands on purpose as the symbolic link node might be
25+
# linked to either out/Debug/node or out/Release/node depending on the
26+
# BUILDTYPE.
27+
$SFW --remove "$NODE_DEBUG"
28+
$SFW --remove "$NODE_DEBUG"
29+
$SFW --remove "$NODE_RELEASE"
30+
$SFW --remove "$NODE_RELEASE"
31+
$SFW --remove "$NODE_LINK"
32+
$SFW --remove "$CCTEST_DEBUG"
33+
$SFW --remove "$CCTEST_RELEASE"
34+
35+
$SFW --add "$NODE_DEBUG"
36+
$SFW --add "$NODE_RELEASE"
37+
$SFW --add "$NODE_LINK"
38+
$SFW --add "$CCTEST_DEBUG"
39+
$SFW --add "$CCTEST_RELEASE"
40+
41+
$SFW --unblock "$NODE_DEBUG"
42+
$SFW --unblock "$NODE_RELEASE"
43+
$SFW --unblock "$NODE_LINK"
44+
$SFW --unblock "$CCTEST_DEBUG"
45+
$SFW --unblock "$CCTEST_RELEASE"
46+
else
47+
echo "SocketFirewall not found in location: $SFW"
48+
fi

0 commit comments

Comments
 (0)