From 80a822e07921b0d1325bec0b28f4001550ebddd2 Mon Sep 17 00:00:00 2001 From: Scott Kuhl Date: Fri, 7 Jan 2022 13:21:16 -0500 Subject: [PATCH] Fix flake8 and unit test errors introduced by use_pty fixes. --- sshuttle/firewall.py | 2 ++ tests/client/test_firewall.py | 2 +- tests/client/test_helpers.py | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/sshuttle/firewall.py b/sshuttle/firewall.py index 28167e3..84b249d 100644 --- a/sshuttle/firewall.py +++ b/sshuttle/firewall.py @@ -15,6 +15,7 @@ from sshuttle.methods import get_auto_method, get_method HOSTSFILE = '/etc/hosts' sshuttle_pid = None + def rewrite_etc_hosts(hostmap, port): BAKFILE = '%s.sbak' % HOSTSFILE APPEND = '# sshuttle-firewall-%d AUTOCREATED' % port @@ -55,6 +56,7 @@ def restore_etc_hosts(hostmap, port): debug2('undoing /etc/hosts changes.') rewrite_etc_hosts({}, port) + def firewall_exit(signum, frame): # The typical sshuttle exit is that the main sshuttle process # exits, closes file descriptors it uses, and the firewall process diff --git a/tests/client/test_firewall.py b/tests/client/test_firewall.py index d249361..76aac89 100644 --- a/tests/client/test_firewall.py +++ b/tests/client/test_firewall.py @@ -15,7 +15,7 @@ NSLIST {inet},1.2.3.33 {inet6},2404:6800:4004:80c::33 PORTS 1024,1025,1026,1027 -GO 1 - 0x01 +GO 1 - 0x01 12345 HOST 1.2.3.3,existing """.format(inet=AF_INET, inet6=AF_INET6)) stdout = Mock() diff --git a/tests/client/test_helpers.py b/tests/client/test_helpers.py index 45e7ea5..8e69d45 100644 --- a/tests/client/test_helpers.py +++ b/tests/client/test_helpers.py @@ -24,19 +24,19 @@ def test_log(mock_stderr, mock_stdout): call.flush(), ] assert mock_stderr.mock_calls == [ - call.write('prefix: message\n'), + call.write('prefix: message\r\n'), call.flush(), - call.write('prefix: abc\n'), + call.write('prefix: abc\r\n'), call.flush(), - call.write('prefix: message 1\n'), + call.write('prefix: message 1\r\n'), call.flush(), - call.write('prefix: message 2\n'), - call.write(' line2\n'), - call.write(' line3\n'), + call.write('prefix: message 2\r\n'), + call.write(' line2\r\n'), + call.write(' line3\r\n'), call.flush(), - call.write('prefix: message 3\n'), - call.write(' line2\n'), - call.write(' line3\n'), + call.write('prefix: message 3\r\n'), + call.write(' line2\r\n'), + call.write(' line3\r\n'), call.flush(), ] @@ -51,7 +51,7 @@ def test_debug1(mock_stderr, mock_stdout): call.flush(), ] assert mock_stderr.mock_calls == [ - call.write('prefix: message\n'), + call.write('prefix: message\r\n'), call.flush(), ] @@ -76,7 +76,7 @@ def test_debug2(mock_stderr, mock_stdout): call.flush(), ] assert mock_stderr.mock_calls == [ - call.write('prefix: message\n'), + call.write('prefix: message\r\n'), call.flush(), ] @@ -101,7 +101,7 @@ def test_debug3(mock_stderr, mock_stdout): call.flush(), ] assert mock_stderr.mock_calls == [ - call.write('prefix: message\n'), + call.write('prefix: message\r\n'), call.flush(), ]