Skip to content

Commit 53c07f7

Browse files
committed
hostmap shouldn't be global.
1 parent 7e0c153 commit 53c07f7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sshuttle/firewall.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
from sshuttle.helpers import debug1, debug2, Fatal
1010
from sshuttle.methods import get_auto_method, get_method
1111

12-
hostmap = {}
1312
HOSTSFILE = '/etc/hosts'
1413

1514

16-
def rewrite_etc_hosts(port):
15+
def rewrite_etc_hosts(hostmap, port):
1716
BAKFILE = '%s.sbak' % HOSTSFILE
1817
APPEND = '# sshuttle-firewall-%d AUTOCREATED' % port
1918
old_content = ''
@@ -48,9 +47,7 @@ def rewrite_etc_hosts(port):
4847

4948

5049
def restore_etc_hosts(port):
51-
global hostmap
52-
hostmap = {}
53-
rewrite_etc_hosts(port)
50+
rewrite_etc_hosts({}, port)
5451

5552

5653
# Isolate function that needs to be replaced for tests
@@ -87,6 +84,7 @@ def setup_daemon():
8784
# are hopefully harmless.
8885
def main(method_name, syslog):
8986
stdin, stdout = setup_daemon()
87+
hostmap = {}
9088

9189
debug1('firewall manager: Starting firewall with Python version %s\n'
9290
% platform.python_version())
@@ -222,7 +220,7 @@ def main(method_name, syslog):
222220
(name, ip) = line[5:].strip().split(',', 1)
223221
hostmap[name] = ip
224222
debug2('firewall manager: setting up /etc/hosts.\n')
225-
rewrite_etc_hosts(port_v6 or port_v4)
223+
rewrite_etc_hosts(hostmap, port_v6 or port_v4)
226224
elif line:
227225
if not method.firewall_command(line):
228226
raise Fatal('firewall: expected command, got %r' % line)

0 commit comments

Comments
 (0)