From 90a55a33a255941081623b6efe03789f6fc5c86a Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 26 Feb 2011 17:45:27 -0800 Subject: [PATCH] firewall.py: make it super clear when we apply the MacOS fix. Print a message to stderr, then abort. But only the first time. --- firewall.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/firewall.py b/firewall.py index 4307bb0..4fd8c79 100644 --- a/firewall.py +++ b/firewall.py @@ -150,7 +150,7 @@ def sysctl_set(name, val, permanent=False): _fill_oldctls(PREFIX) if not (name in _oldctls): debug1('>> No such sysctl: %r\n' % name) - return + return False oldval = _oldctls[name] if val != oldval: rv = _sysctl_set(name, val) @@ -163,6 +163,7 @@ def sysctl_set(name, val, permanent=False): f.close() else: _changedctls.append(name) + return True def _udp_unpack(p): @@ -221,7 +222,18 @@ def do_ipfw(port, dnsport, subnets): if subnets or dnsport: sysctl_set('net.inet.ip.fw.enable', 1) - sysctl_set('net.inet.ip.scopedroute', 0, permanent=True) + changed = sysctl_set('net.inet.ip.scopedroute', 0, permanent=True) + if changed: + log("\n" + " WARNING: ONE-TIME NETWORK DISRUPTION:\n" + " =====================================\n" + "sshuttle has changed a MacOS kernel setting to work around\n" + "a bug in MacOS 10.6. This will cause your network to drop\n" + "within 5-10 minutes unless you restart your network\n" + "interface (change wireless networks or unplug/plug the\n" + "ethernet port) NOW, then restart sshuttle. The fix is\n" + "permanent; you only have to do this once.\n\n") + sys.exit(1) ipfw('add', sport, 'check-state', 'ip', 'from', 'any', 'to', 'any')