Skip to content

Conversation

@brianmay
Copy link
Member

Under Python 3.8 we can not wrap a File in a Sock.

Note this currently requires Python >= 3.5


def __init__(self, mux, channel):
SockWrapper.__init__(self, mux.rsock, mux.wsock)
SockWrapper.__init__(self, mux.rfile, mux.wfile)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird that SockWrapper needs to be able to work with files and socks.

@outime
Copy link

outime commented May 20, 2020

@brianmay are you planning to merge this soon?

@brianmay
Copy link
Member Author

@outime I am anticipating people will get upset when they realize I dropped support for Python 2.4. See #56.

But I somewhat think it is time to drop support for Python 2.x. Maybe apply the scream test. As in apply this change and see if anyone screams about it...

Anybody able to test this with Python 3.8? I only have Python 3.7 on my servers. I think it should work...

@brianmay
Copy link
Member Author

This should fix #381

@thesurlydev
Copy link

@outime I am anticipating people will get upset when they realize I dropped support for Python 2.4. See #56.

But I somewhat think it is time to drop support for Python 2.x. Maybe apply the scream test. As in apply this change and see if anyone screams about it...

Anybody able to test this with Python 3.8? I only have Python 3.7 on my servers. I think it should work...

I just tried this with 3.8 and still getting the following:

Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 3.8.2
firewall manager: ready method name nat.
IPv6 enabled: None
UDP enabled: False
DNS enabled: True
User enabled: False
Binding redirector: 12300
TCP redirector listening on ('127.0.0.1', 12300).
TCP redirector listening with <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 12300)>.
Binding DNS: 12300 12299
DNS listening on ('127.0.0.1', 12299).
DNS listening with <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 12299)>.
Starting client with Python version 3.8.2
c : connecting to server...
c : executing: ['ssh', '-p', '22', 'Shane Witbeck@laptop', '--', '\'/Users/switbe/.pyenv/versions/3.7.5/bin/python\' -c \'import sys, os; verbosity=3; sys.stdin = os.fdopen(0, "rb"); exec(compile(sys.stdin.read(1275), "assembler.py", "exec"))\'']
c :  > channel=0 cmd=PING len=7 (fullness=0)
-c:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
server: assembling 'sshuttle' (7 bytes)
server: assembling 'sshuttle.cmdline_options' (66 bytes)
server: assembling 'sshuttle.helpers' (955 bytes)
server: assembling 'sshuttle.ssnet' (5716 bytes)
server: assembling 'sshuttle.hostwatch' (2467 bytes)
server: assembling 'sshuttle.server' (3786 bytes)
Starting server with Python version 3.7.5
 s: latency control setting = True
 s:  > channel=0 cmd=PING len=7 (fullness=0)
 s: auto-nets:False
 s:  > channel=0 cmd=ROUTES len=0 (fullness=7)
 s: Waiting: 1 r=[4] w=[5] x=[] (fullness=7/0)
 s:   Ready: 1 r=[] w=[5] x=[]
 s: mux wrote: 15/15
 s: Waiting: 1 r=[4] w=[5] x=[] (fullness=7/0)
 s:   Ready: 1 r=[] w=[5] x=[]
 s: mux wrote: 8/8
 s: Waiting: 1 r=[4] w=[] x=[] (fullness=7/0)
c : Connected.
c : Waiting: 3 r=[5, 7, 9] w=[9] x=[] (fullness=7/0)
c :   Ready: 3 r=[9] w=[9] x=[]
c : <  channel=0 cmd=PING len=7
c :  > channel=0 cmd=PONG len=7 (fullness=7)
c : <  channel=0 cmd=ROUTES len=0
firewall manager: Got subnets: [(2, 0, False, '0.0.0.0', 0, 0)]
firewall manager: Got partial nslist: [(2, '127.0.0.53')]
firewall manager: Got nslist: [(2, '127.0.0.53')]
firewall manager: Got ports: 0,12300,0,12299
firewall manager: Got udp: False, user: None
firewall manager: setting up.
firewall manager: setting up IPv4.
>> iptables -t nat -N sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -I OUTPUT 1 -j sshuttle-12300
>> iptables -t nat -I PREROUTING 1 -j sshuttle-12300
>> iptables -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL ! -p udp
>> iptables -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL -p udp ! --dport 53
>> iptables -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300 -m ttl ! --ttl 42
>> iptables -t nat -A sshuttle-12300 -j REDIRECT --dest 127.0.0.53/32 -p udp --dport 53 --to-ports 12299 -m ttl ! --ttl 42
c : mux wrote: 15/15
c : mux wrote: 15/15
client_loop: send disconnect: Broken pipe
c : Waiting: 3 r=[5, 7, 9] w=[] x=[] (fullness=14/0)
c :   Ready: 3 r=[9] w=[] x=[]
firewall manager: undoing changes.
firewall manager: undoing IPv4 changes.
>> iptables -t nat -D OUTPUT -j sshuttle-12300
>> iptables -t nat -D PREROUTING -j sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -X sshuttle-12300
firewall manager: undoing /etc/hosts changes.
c : fatal: server died with error code 255
shane@beefcake:~$ sshuttle --version
0.78.6.dev45+gf674aac.d20200520

@brianmay
Copy link
Member Author

brianmay commented May 21, 2020 via email

@outime
Copy link

outime commented May 21, 2020

Shane Witbeck notifications@github.com writes:
I just tried this with 3.8 and still getting the following:
Not good. Can I please verify if this works for you? * With Python 3.7 with this change? * With Python 3.7 without this change? -- Brian May brian@linuxpenguins.xyz https://linuxpenguins.xyz/brian/

Not Shane but earlier today I ran the pip release with the latest Python 3.7 and worked fine. Haven't tried with this change.

@thesurlydev
Copy link

Not good. Can I please verify if this works for you?

  • With Python 3.7 with this change?
  • With Python 3.7 without this change?

I get the same result (not working with and without change) using Python 3.7.7 client with 3.7.5 server:

Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 3.7.7
firewall manager: ready method name nat.
IPv6 enabled: None
UDP enabled: False
DNS enabled: True
User enabled: False
Binding redirector: 12300
TCP redirector listening on ('127.0.0.1', 12300).
TCP redirector listening with <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 12300)>.
Binding DNS: 12300 12299
DNS listening on ('127.0.0.1', 12299).
DNS listening with <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('127.0.0.1', 12299)>.
Starting client with Python version 3.7.7
c : connecting to server...
c : executing: ['ssh', '-p', '22', 'Shane Witbeck@laptop', '--', '\'/Users/switbe/.pyenv/versions/3.7.5/bin/python\' -c \'import sys, os; verbosity=3; sys.stdin = os.fdopen(0, "rb"); exec(compile(sys.stdin.read(1275), "assembler.py", "exec"))\'']
c :  > channel=0 cmd=PING len=7 (fullness=0)
-c:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
server: assembling 'sshuttle' (7 bytes)
server: assembling 'sshuttle.cmdline_options' (66 bytes)
server: assembling 'sshuttle.helpers' (955 bytes)
server: assembling 'sshuttle.ssnet' (5712 bytes)
server: assembling 'sshuttle.hostwatch' (2468 bytes)
server: assembling 'sshuttle.server' (3786 bytes)
Starting server with Python version 3.7.5
 s: latency control setting = True
 s:  > channel=0 cmd=PING len=7 (fullness=0)
 s: auto-nets:False
 s:  > channel=0 cmd=ROUTES len=0 (fullness=7)
 s: Waiting: 1 r=[4] w=[5] x=[] (fullness=7/0)
 s:   Ready: 1 r=[] w=[5] x=[]
 s: mux wrote: 15/15
 s: Waiting: 1 r=[4] w=[5] x=[] (fullness=7/0)
 s:   Ready: 1 r=[] w=[5] x=[]
 s: mux wrote: 8/8
 s: Waiting: 1 r=[4] w=[] x=[] (fullness=7/0)
c : Connected.
c : Waiting: 3 r=[5, 7, 9] w=[9] x=[] (fullness=7/0)
c :   Ready: 3 r=[9] w=[9] x=[]
c : <  channel=0 cmd=PING len=7
c :  > channel=0 cmd=PONG len=7 (fullness=7)
c : <  channel=0 cmd=ROUTES len=0
firewall manager: Got subnets: [(2, 0, False, '0.0.0.0', 0, 0)]
firewall manager: Got partial nslist: [(2, '127.0.0.53')]
firewall manager: Got nslist: [(2, '127.0.0.53')]
firewall manager: Got ports: 0,12300,0,12299
firewall manager: Got udp: False, user: None
firewall manager: setting up.
firewall manager: setting up IPv4.
>> iptables -t nat -N sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -I OUTPUT 1 -j sshuttle-12300
>> iptables -t nat -I PREROUTING 1 -j sshuttle-12300
>> iptables -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL ! -p udp
>> iptables -t nat -A sshuttle-12300 -j RETURN -m addrtype --dst-type LOCAL -p udp ! --dport 53
>> iptables -t nat -A sshuttle-12300 -j REDIRECT --dest 0.0.0.0/0 -p tcp --to-ports 12300 -m ttl ! --ttl 42
>> iptables -t nat -A sshuttle-12300 -j REDIRECT --dest 127.0.0.53/32 -p udp --dport 53 --to-ports 12299 -m ttl ! --ttl 42
c : mux wrote: 15/15
c : mux wrote: 15/15
c : Waiting: 3 r=[5, 7, 9] w=[] x=[] (fullness=14/0)
client_loop: send disconnect: Broken pipe
c :   Ready: 3 r=[9] w=[] x=[]
firewall manager: undoing changes.
firewall manager: undoing IPv4 changes.
>> iptables -t nat -D OUTPUT -j sshuttle-12300
>> iptables -t nat -D PREROUTING -j sshuttle-12300
>> iptables -t nat -F sshuttle-12300
>> iptables -t nat -X sshuttle-12300
firewall manager: undoing /etc/hosts changes.
c : fatal: server died with error code 255

@thesurlydev
Copy link

Please disregard my comment above. My issue seems not related to Python version and was able to get things working again. See: #434 (comment)

@brianmay
Copy link
Member Author

OK, that makes more sense, thanks for the update.

Not that I really trust this PR. I tested it for about 10 seconds, it it appeared to work fine for me...

brianmay added 2 commits May 29, 2020 07:39
Under Python 3.8 we can not wrap a File in a Sock.

Note this currently requires Python >= 3.5
* Drop 2.7
* Add 3.7 and 3.8
@brianmay
Copy link
Member Author

This does seem to work for me. I am going to use the scream test as a reliable way of testing if (a) this works for everybody and (b) people are happy dropping Python 2.7 support. Merging...

@brianmay brianmay merged commit 9f27c19 into master May 28, 2020
@brianmay brianmay deleted the fix_python_38 branch May 28, 2020 21:44
@andrewdunndev
Copy link

Sorry to bump a merged PR, curious though, when will this hit in a release?

@brianmay
Copy link
Member Author

brianmay commented Jun 4, 2020

Version 1.0.1 now released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants