Skip to content

Commit fae4cb1

Browse files
vieirabrianmay
authored andcommitted
Override the skip on lo that ends up in the chain
In some cases (see apenwarr#43) it seems that some network configurations may end up setting a skip on lo. As sshuttle adds rules that rely on filtering/translating packets on lo, this causes problem. This fix overrides the skip and makes the rules be applied again. Should fix at least some of the problems reported on apenwarr#43.
1 parent 7d8309e commit fae4cb1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

sshuttle/methods/pf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ def disable(self):
235235
if _pf_context['Xtoken'] is not None:
236236
pfctl('-X %s' % _pf_context['Xtoken'].decode("ASCII"))
237237

238+
def add_anchors(self):
239+
# before adding anchors and rules we must override the skip lo
240+
# that in some cases ends up in the chain so the rules we will add,
241+
# which rely on translating/filtering packets on lo, can work
242+
pfctl('-f /dev/stdin', b'pass on lo\n')
243+
super(Darwin, self).add_anchors()
244+
238245
def _add_natlook_ports(self, pnl, src_port, dst_port):
239246
pnl.sxport.port = socket.htons(src_port)
240247
pnl.dxport.port = socket.htons(dst_port)

sshuttle/tests/test_methods_pf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def test_setup_firewall_darwin(mock_pf_get_dev, mock_ioctl, mock_pfctl):
192192
call(mock_pf_get_dev(), 0xCC20441A, ANY),
193193
]
194194
assert mock_pfctl.mock_calls == [
195+
call('-f /dev/stdin', 'pass on lo\n'),
195196
call('-s all'),
196197
call('-a sshuttle -f /dev/stdin',
197198
b'table <forward_subnets> {!1.2.3.66/32,1.2.3.0/24}\n'

0 commit comments

Comments
 (0)