| 
 | 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