From 7a5201d21a0ba3cf2a4bff18af09e4b706e9f59b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sat, 3 Dec 2016 07:56:01 +0100 Subject: [PATCH 1/7] 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: https://github.com/nodejs/node/issues/8911 --- BUILDING.md | 1 + tools/macosx-firewall.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 tools/macosx-firewall.sh diff --git a/BUILDING.md b/BUILDING.md index 5051da343353b3..86d6d330d60db2 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -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 diff --git a/tools/macosx-firewall.sh b/tools/macosx-firewall.sh new file mode 100755 index 00000000000000..77f12131b4a5b2 --- /dev/null +++ b/tools/macosx-firewall.sh @@ -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 From c39bf95d0acfb86dd2befa23ab0f88195f13fe36 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 5 Dec 2016 09:48:52 +0100 Subject: [PATCH 2/7] fix long line --- BUILDING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 86d6d330d60db2..a1b06e42c2176c 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -23,7 +23,8 @@ 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. + * 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 From d255df9b8bbaa68212595ab9ea23bb94ceab9ee3 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 5 Dec 2016 09:52:44 +0100 Subject: [PATCH 3/7] quote variables to allow for paths with spaces --- tools/macosx-firewall.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/macosx-firewall.sh b/tools/macosx-firewall.sh index 77f12131b4a5b2..cee606d1225d3b 100755 --- a/tools/macosx-firewall.sh +++ b/tools/macosx-firewall.sh @@ -6,30 +6,30 @@ SFW="/usr/libexec/ApplicationFirewall/socketfilterfw" TOOLSDIR="`dirname \"$0\"`" TOOLSDIR="`( cd \"$TOOLSDIR\" && pwd) `" ROOTDIR="`( cd \"$TOOLSDIR/..\" && pwd) `" -OUTDIR=$TOOLSDIR/../out +OUTDIR="$TOOLSDIR/../out" OUTDIR="`( cd \"$OUTDIR\" && pwd) `" -NODE_RELEASE=$OUTDIR/Release/node -NODE_DEBUG=$OUTDIR/Debug/node -NODE_LINK=$ROOTDIR/node +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 --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 --add "$NODE_DEBUG" + $SFW --add "$NODE_RELEASE" + $SFW --add "$NODE_LINK" - $SFW --unblock $NODE_DEBUG - $SFW --unblock $NODE_RELEASE - $SFW --unblock $NODE_LINK + $SFW --unblock "$NODE_DEBUG" + $SFW --unblock "$NODE_RELEASE" + $SFW --unblock "$NODE_LINK" else echo "SocketFirewall not found in location: $SFW" fi From e546655984ab864af437efd44cf1b17547ceec1f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 5 Dec 2016 20:34:08 +0100 Subject: [PATCH 4/7] add comment explaining the usage of cd and pwd --- tools/macosx-firewall.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/macosx-firewall.sh b/tools/macosx-firewall.sh index cee606d1225d3b..93ae37c2cf5c53 100755 --- a/tools/macosx-firewall.sh +++ b/tools/macosx-firewall.sh @@ -7,6 +7,11 @@ TOOLSDIR="`dirname \"$0\"`" TOOLSDIR="`( cd \"$TOOLSDIR\" && pwd) `" ROOTDIR="`( cd \"$TOOLSDIR/..\" && pwd) `" OUTDIR="$TOOLSDIR/../out" +# Using cd and pwd here so that the path used for socketfilterfw does not +# contain a '..', which seems to cause the rules to be incorrectly added +# and they are not removed when this script is re-run. Instead the new +# rules are simply appended. By using pwd we can get the full path +# without '..' and things work as expected. OUTDIR="`( cd \"$OUTDIR\" && pwd) `" NODE_RELEASE="$OUTDIR/Release/node" NODE_DEBUG="$OUTDIR/Debug/node" From 4f29ee57032f360f9a042f5c3e697c1d35870589 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 5 Dec 2016 20:43:49 +0100 Subject: [PATCH 5/7] show usage os running the script Also a short description of what the script does. --- BUILDING.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index a1b06e42c2176c..8bae1540c3a6e1 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -23,8 +23,14 @@ 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. + +* You may want to setup [firewall rules](tools/macosx-firewall.sh) to avoid +popups asking to accept incoming network connections when running tests: + +```console +$ sudo ./tools/macosx-firewall.sh +``` +Running this script will add rules for the executable `node` in the out directory and the symbolic `node` link in the projects root directory. On FreeBSD and OpenBSD, you may also need: * libexecinfo From 46ad90977efa6994d6ac4b65d01cd38ba3f7eff3 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 6 Dec 2016 08:06:24 +0100 Subject: [PATCH 6/7] fix lone line --- BUILDING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 8bae1540c3a6e1..b1060744f75d24 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -30,7 +30,8 @@ popups asking to accept incoming network connections when running tests: ```console $ sudo ./tools/macosx-firewall.sh ``` -Running this script will add rules for the executable `node` in the out directory and the symbolic `node` link in the projects root directory. +Running this script will add rules for the executable `node` in the out +directory and the symbolic `node` link in the projects root directory. On FreeBSD and OpenBSD, you may also need: * libexecinfo From cef43de91c847e4d77c4af3ac064dbc08dc7cf0c Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 7 Dec 2016 07:52:29 +0100 Subject: [PATCH 7/7] add cctest to firewall script I forgot about cctest which will also show up at times. --- tools/macosx-firewall.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/macosx-firewall.sh b/tools/macosx-firewall.sh index 93ae37c2cf5c53..c1de916e3c87ea 100755 --- a/tools/macosx-firewall.sh +++ b/tools/macosx-firewall.sh @@ -16,6 +16,8 @@ OUTDIR="`( cd \"$OUTDIR\" && pwd) `" NODE_RELEASE="$OUTDIR/Release/node" NODE_DEBUG="$OUTDIR/Debug/node" NODE_LINK="$ROOTDIR/node" +CCTEST_RELEASE="$OUTDIR/Release/cctest" +CCTEST_DEBUG="$OUTDIR/Debug/cctest" if [ -f $SFW ]; then @@ -27,14 +29,20 @@ then $SFW --remove "$NODE_RELEASE" $SFW --remove "$NODE_RELEASE" $SFW --remove "$NODE_LINK" + $SFW --remove "$CCTEST_DEBUG" + $SFW --remove "$CCTEST_RELEASE" $SFW --add "$NODE_DEBUG" $SFW --add "$NODE_RELEASE" $SFW --add "$NODE_LINK" + $SFW --add "$CCTEST_DEBUG" + $SFW --add "$CCTEST_RELEASE" $SFW --unblock "$NODE_DEBUG" $SFW --unblock "$NODE_RELEASE" $SFW --unblock "$NODE_LINK" + $SFW --unblock "$CCTEST_DEBUG" + $SFW --unblock "$CCTEST_RELEASE" else echo "SocketFirewall not found in location: $SFW" fi