Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add macosx-firewall script to avoid popups #10114

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should specify a bit more how to run it an some implications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fishrock123 I've added as suggestion, let me know what you think. Thanks


On FreeBSD and OpenBSD, you may also need:
* libexecinfo
Expand Down
35 changes: 35 additions & 0 deletions tools/macosx-firewall.sh
Original file line number Diff line number Diff line change
@@ -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) `"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the cd + pwd to ensure the directory exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is really so that the path added is the full path without the .. in it. This is what is displayed when the command is run (if using .. in that path that is):

Application at path ( /Users/danielbevenius/work/nodejs/node/tools/../out/Debug/node ) added to firewall

But the entry when running /usr/libexec/ApplicationFirewall/socketfilterfw --listapps shows up without the path. Running the script again will not remove these paths, instead the new rules will just be added and the list will grow. But with the full path (without ..) it works as expected and the rules are removed and added properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining the use of pwd (what you wrote in your comment earlier)?

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