1#!/bin/sh 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. 5SFW="/usr/libexec/ApplicationFirewall/socketfilterfw" 6TOOLSDIR="`dirname \"$0\"`" 7TOOLSDIR="`( cd \"$TOOLSDIR\" && pwd) `" 8ROOTDIR="`( cd \"$TOOLSDIR/..\" && pwd) `" 9OUTDIR="$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. 15OUTDIR="`( cd \"$OUTDIR\" && pwd) `" 16NODE_RELEASE="$OUTDIR/Release/node" 17NODE_DEBUG="$OUTDIR/Debug/node" 18NODE_LINK="$ROOTDIR/node" 19CCTEST_RELEASE="$OUTDIR/Release/cctest" 20CCTEST_DEBUG="$OUTDIR/Debug/cctest" 21OPENSSL_CLI_RELEASE="$OUTDIR/Release/openssl-cli" 22OPENSSL_CLI_DEBUG="$OUTDIR/Debug/openssl-cli" 23 24add_and_unblock () { 25 if [ -e "$1" ] 26 then 27 echo Processing "$1" 28 $SFW --remove "$1" >/dev/null 29 $SFW --add "$1" 30 $SFW --unblock "$1" 31 fi 32} 33 34if [ -f $SFW ]; 35then 36 add_and_unblock "$NODE_DEBUG" 37 add_and_unblock "$NODE_RELEASE" 38 add_and_unblock "$NODE_LINK" 39 add_and_unblock "$CCTEST_DEBUG" 40 add_and_unblock "$CCTEST_RELEASE" 41 add_and_unblock "$OPENSSL_CLI_DEBUG" 42 add_and_unblock "$OPENSSL_CLI_RELEASE" 43else 44 echo "SocketFirewall not found in location: $SFW" 45fi 46