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.
This commit is contained in:
Avery Pennarun 2010-05-02 21:06:31 -04:00
parent ea6bb5c255
commit a5fc93c841

View File

@ -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()