summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-05-02 21:06:31 -0400
committerAvery Pennarun <apenwarr@gmail.com>2010-05-02 21:06:31 -0400
commita5fc93c8412f161c86af2275e8e7f8dde3b59b81 (patch)
tree55fcb2c9742a452af7f182e86fbb1507fb46270c
parentea6bb5c255e2aeeffbc1748238058dea4faab2f7 (diff)
iptables: if client dies before sending GO, just quit.
If the server was having trouble starting, we would print a lot of unnecessary stuff from iptables. We shouldn't even have bothered *starting* iptables if the server was dead anyway.
-rw-r--r--iptables.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/iptables.py b/iptables.py
index 92fd937..6ad216f 100644
--- a/iptables.py
+++ b/iptables.py
@@ -85,12 +85,16 @@ def main(port, subnets):
# we wait until we get some input before creating the rules. That way,
# sshuttle can launch us as early as possible (and get sudo password
# authentication as early in the startup process as possible).
- sys.stdin.readline(128)
+ line = sys.stdin.readline(128)
+ if not line:
+ return # parent died; nothing to do
+ if line != 'GO\n':
+ raise Fatal('iptables: expected GO but got %r' % line)
try:
- debug1('iptables manager: starting transproxy.\n')
- do_it(port, subnets)
-
- sys.stdout.write('STARTED\n')
+ if line:
+ debug1('iptables manager: starting transproxy.\n')
+ do_it(port, subnets)
+ sys.stdout.write('STARTED\n')
try:
sys.stdout.flush()