2020-11-10 23:26:07 +00:00
|
|
|
#!/bin/sh
|
2016-12-03 06:56:01 +00:00
|
|
|
# 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"
|
2022-04-14 22:08:55 +00:00
|
|
|
TOOLSDIR="$(dirname "$0")"
|
|
|
|
TOOLSDIR="$(cd "$TOOLSDIR" && pwd)"
|
|
|
|
ROOTDIR="$(cd "$TOOLSDIR/.." && pwd)"
|
2016-12-03 06:56:01 +00:00
|
|
|
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.
|
2022-04-14 22:08:55 +00:00
|
|
|
OUTDIR="$(cd "$OUTDIR" && pwd)"
|
2016-12-03 06:56:01 +00:00
|
|
|
NODE_RELEASE="$OUTDIR/Release/node"
|
|
|
|
NODE_DEBUG="$OUTDIR/Debug/node"
|
|
|
|
NODE_LINK="$ROOTDIR/node"
|
|
|
|
CCTEST_RELEASE="$OUTDIR/Release/cctest"
|
|
|
|
CCTEST_DEBUG="$OUTDIR/Debug/cctest"
|
2019-01-08 04:58:08 +00:00
|
|
|
OPENSSL_CLI_RELEASE="$OUTDIR/Release/openssl-cli"
|
|
|
|
OPENSSL_CLI_DEBUG="$OUTDIR/Debug/openssl-cli"
|
2016-12-03 06:56:01 +00:00
|
|
|
|
2021-03-20 18:53:47 +00:00
|
|
|
add_and_unblock () {
|
|
|
|
if [ -e "$1" ]
|
|
|
|
then
|
|
|
|
echo Processing "$1"
|
|
|
|
$SFW --remove "$1" >/dev/null
|
|
|
|
$SFW --add "$1"
|
|
|
|
$SFW --unblock "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-12-03 06:56:01 +00:00
|
|
|
if [ -f $SFW ];
|
|
|
|
then
|
2021-03-20 18:53:47 +00:00
|
|
|
add_and_unblock "$NODE_DEBUG"
|
|
|
|
add_and_unblock "$NODE_RELEASE"
|
|
|
|
add_and_unblock "$NODE_LINK"
|
|
|
|
add_and_unblock "$CCTEST_DEBUG"
|
|
|
|
add_and_unblock "$CCTEST_RELEASE"
|
|
|
|
add_and_unblock "$OPENSSL_CLI_DEBUG"
|
|
|
|
add_and_unblock "$OPENSSL_CLI_RELEASE"
|
2016-12-03 06:56:01 +00:00
|
|
|
else
|
|
|
|
echo "SocketFirewall not found in location: $SFW"
|
|
|
|
fi
|