Bug 1321580 - sshuttle 0.77.2-1.fc23 fails in Fedora 23 with AttributeError: 'unicode' object has no attribute 'rpartition'
Summary: sshuttle 0.77.2-1.fc23 fails in Fedora 23 with AttributeError: 'unicode' obje...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: sshuttle
Version: 23
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Kevin Fenzi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-28 13:23 UTC by William Bader
Modified: 2016-04-13 07:23 UTC (History)
8 users (show)

Fixed In Version: sshuttle-0.77.3-0.1.20160402git6e15e691.fc24 sshuttle-0.77.3-0.1.20160402git6e15e691.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-08 17:02:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sshuttle sshuttle issues 87 0 None closed AttributeError: 'unicode' object has no attribute 'rpartition' 2020-09-01 07:14:34 UTC

Description William Bader 2016-03-28 13:23:51 UTC
Description of problem:

sshuttle fails with the sequence below after it asks for the password:


me's password:
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 18, in ?
AttributeError: 'unicode' object has no attribute 'rpartition'
client: fatal: server died with error code 1


Version-Release number of selected component (if applicable):

sshuttle-0.77.2-1.fc23.noarch

I used "dnf downgrade sshuttle" to restore the previous version, which is sshuttle-0-11.20120810git9ce2fa0.fc23.noarch


How reproducible:

It happens every time.


Steps to Reproduce:
1. run sshuttle and try to connect
2. it happens after asking for the password, so you have to connect using a real account
3.

Actual results:

sshuttle fails with AttributeError: 'unicode' object has no attribute 'rpartition'


Expected results:

Working connection


Additional info:

I think that the bad line is in /usr/lib/python2.7/site-packages/sshuttle/assembler.py

Comment 1 Kevin Fenzi 2016-03-28 16:38:02 UTC
Can you tell us the full command line you are using (feel free to replace ip's/nets, etc). 

Also, does your password happen to contain unicode characters?

Comment 2 William Bader 2016-03-28 21:58:06 UTC
I am running

sudo sshuttle -r user:9000 10.0.0.0/16

The password is only printable 7 bit ascii characters.



$ sudo sshuttle -r xxx.x.x:9xxx 10.0.0.0/16
xxx.x.x's password: 
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 18, in ?
AttributeError: 'unicode' object has no attribute 'rpartition'
client: fatal: server died with error code 1

Comment 3 Fernando Gomes 2016-03-30 21:00:04 UTC
Hi,

Same problem here:

sshuttle -v -r user 10.0.0.0/16 192.168.0.0/24
Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 2.7.10
firewall manager: ready method name nat.
IPv6 enabled: False
UDP enabled: False
DNS enabled: False
TCP redirector listening on ('127.0.0.1', 12300).
Starting client with Python version 2.7.10
c : connecting to server...
X11 forwarding request failed on channel 0
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 18, in ?
AttributeError: 'unicode' object has no attribute 'rpartition'
c : fatal: server died with error code 1

Comment 4 Rodrigo Araujo 2016-04-01 15:51:46 UTC
Good afternoon.

Updated to f23 recently and I'm having this exact same issue: sshuttle simply does not work. By downgrading the package, it works.

To reproduce: just try to use it.

Best regards.

Comment 5 Rodrigo Araujo 2016-04-01 16:08:25 UTC
Hello.

Some more insight follows.

It works if I do sshuttle to a recent system, like f23. But if I try to RHEL 5 or RHEL 6, it just fails.

Seems to me the new version always expects python 3 to be present on the other side? If so, the new version is useless for anyone that has to manage older (but still supported) systems.

Comment 6 Jonathan Underwood 2016-04-01 16:46:53 UTC
Yes, the new sshuttle upstream release which we have moved to currently requires python either 2.7 or 3.5 on both ends.

There is work on supporting 2.4 on the server end:

https://github.com/sshuttle/sshuttle/pull/81

.. but its not yet complete.

Comment 7 William Bader 2016-04-01 17:11:27 UTC
[The previous comment came while I was writing this.]
On my F23 laptop, I tested
  sudo sshuttle -v -r user.com 10.0.0.0/16
I could connect to CentOS 7 but not to CentOS 5.
Neither of these servers have python 3 installed.
The "Starting server with Python version 2.7.5" line shows that it is running python2 on the target.
The CentOS 7 server has Python 2.7.5, while the CentOS 5 server has Python 2.4.3. It also works with my CentOS 6 server as the target, which has Python 2.6.6.

It looks like rpartition was added in Python 2.5.
https://bytes.com/topic/python/answers/537988-new-string-method-2-5-partition

I think that the problem is that the updated sshuttle uses rpartition which requires a target with Python 2.5 or later.

Could the new sshuttle code be written to use another method to implement the rpartition or to revert to the old sshuttle code with older versions of python?

---

When the target is CentOS 7, I get
sudo sshuttle -v -r user@centos7 10.0.0.0/16
Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 2.7.10
firewall manager: ready method name nat.
IPv6 enabled: False
UDP enabled: False
DNS enabled: False
TCP redirector listening on ('127.0.0.1', 12300).
Starting client with Python version 2.7.10
c : connecting to server...
user@centos7's password: 
Starting server with Python version 2.7.5
 s: latency control setting = True
 s: available routes:
 s:   2/10.0.0.0/16
 s:   2/192.168.122.0/24
c : Connected.
firewall manager: setting up.
>> 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 REDIRECT --dest 10.0.0.0/16 -p tcp --to-ports 12300 -m ttl ! --ttl 42
>> iptables -t nat -A sshuttle-12300 -j RETURN --dest 127.0.0.0/8 -p tcp

When the target is CentOS 5, I get
sudo sshuttle -v -r user@centos5 10.0.0.0/16
Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 2.7.10
firewall manager: ready method name nat.
IPv6 enabled: False
UDP enabled: False
DNS enabled: False
TCP redirector listening on ('127.0.0.1', 12300).
Starting client with Python version 2.7.10
c : connecting to server...
user@centos5's password: 
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 18, in ?
AttributeError: 'unicode' object has no attribute 'rpartition'
c : fatal: server died with error code 1

---

Section of new /usr/lib/python2.7/site-packages/sshuttle/assembler.py

        content = z.decompress(stdin.read(nbytes))

        module = imp.new_module(name)
        parent, _, parent_name = name.rpartition(".")
        if parent != "":
            setattr(sys.modules[parent], parent_name, module)

        code = compile(content, name, "exec")
        exec(code, module.__dict__)
        sys.modules[name] = module

Corresponding section of old /usr/share/sshuttle/assembler.py

        content = z.decompress(sys.stdin.read(nbytes))
        exec compile(content, name, "exec")

        # FIXME: this crushes everything into a single module namespace,
        # then makes each of the module names point at this one. Gross.
        assert(name.endswith('.py'))
        modname = name[:-3]
        mainmod.__dict__[modname] = mainmod

Comment 8 Jonathan Underwood 2016-04-02 09:59:53 UTC
OK, I have updated the packages to a current git snapshot, and added a patch to enable support for older python on the server end. This is the build of those packages. When it's complete, please test:

http://koji.fedoraproject.org/koji/taskinfo?taskID=13540955

Comment 9 Fedora Update System 2016-04-02 10:08:15 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0d6542f05a

Comment 10 Fedora Update System 2016-04-02 10:13:03 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-844f8350f4

Comment 11 Jonathan Underwood 2016-04-02 11:20:50 UTC
The package can be pulled from this url if you wish to test it before it's available in the updates-testing repo:

https://kojipkgs.fedoraproject.org//work/tasks/964/13540964/sshuttle-0.77.3-0.1.20160402git6e15e691.fc23.noarch.rpm

Comment 12 Fedora Update System 2016-04-02 21:19:39 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0d6542f05a

Comment 13 Fedora Update System 2016-04-02 21:21:30 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-844f8350f4

Comment 14 Fernando Gomes 2016-04-02 23:24:09 UTC
It's working.

Thanks,
Fernando Gomes

Comment 15 Jonathan Underwood 2016-04-02 23:51:32 UTC
(In reply to Fernando Gomes from comment #14)
> It's working.
> 
> Thanks,
> Fernando Gomes

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0d6542f05a

Comment 16 Jonathan Underwood 2016-04-07 13:59:01 UTC
Folks, thanks for adding feedback. But please be aware that if you add feedback without adding karma, it doesn't result in the package being pushed to updates - right now 3 of you left feedback, but only one of you increased the karma.

Comment 17 William Bader 2016-04-07 16:22:14 UTC
It is still broken for me when connecting to CentOS4 but it is now OK for CentOS5.

$ uname -a
Linux laptop.example.com 4.4.6-300.fc23.x86_64 #1 SMP Wed Mar 16 22:10:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ rpm -q sshuttle
sshuttle-0.77.3-0.1.20160402git6e15e691.fc23.noarch
$ sudo sshuttle -v -r william@centos4 10.0.0.0/16
Starting sshuttle proxy.
firewall manager: Starting firewall with Python version 2.7.10
firewall manager: ready method name nat.
IPv6 enabled: False
UDP enabled: False
DNS enabled: False
TCP redirector listening on ('127.0.0.1', 12300).
Starting client with Python version 2.7.10
c : connecting to server...
william@centos4's password: 
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 18, in ?
AttributeError: 'unicode' object has no attribute 'rsplit'
c : fatal: server died with error code 1
$ 


On centos4:
$ uname -a
Linux centos4.example.com 2.6.9-103.EL #1 Fri Dec 9 04:15:51 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release 
CentOS release 4.9 (Final)
$ python -V
Python 2.3.4
$

Comment 18 Jonathan Underwood 2016-04-07 16:36:58 UTC
(In reply to William Bader from comment #17)
> It is still broken for me when connecting to CentOS4 but it is now OK for
> CentOS5.
> 

Yeah, we're not going to fix that. RHEL4/CentOS4 has ancient python, and is no longer supported.

Comment 19 William Bader 2016-04-07 18:27:52 UTC
>is no longer supported.

That is a pity because the previous version of sshuttle could connect to CentOS 4 servers.

I tried changing assembler.py to use rfind() instead of rsplit(), but then it failed with

Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "assembler.py", line 25, in ?
  File "sshuttle.hostwatch", line 10, in ?
ImportError: No module named subprocess
c : fatal: server died with error code 1

Is there a reason why the new version can't use "try" to "import compat.ssubprocess as ssubprocess" if "import subprocess as ssubprocess" fails?

William

Comment 20 Fedora Update System 2016-04-08 17:02:22 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 21 Jonathan Underwood 2016-04-11 18:32:46 UTC
(In reply to William Bader from comment #19)
> >is no longer supported.
> 
> That is a pity because the previous version of sshuttle could connect to
> CentOS 4 servers.
> 
> I tried changing assembler.py to use rfind() instead of rsplit(), but then
> it failed with
> 
> Traceback (most recent call last):
>   File "<string>", line 1, in ?
>   File "assembler.py", line 25, in ?
>   File "sshuttle.hostwatch", line 10, in ?
> ImportError: No module named subprocess
> c : fatal: server died with error code 1
> 
> Is there a reason why the new version can't use "try" to "import
> compat.ssubprocess as ssubprocess" if "import subprocess as ssubprocess"
> fails?

I'm afraid we won't be patching this downstream in Fedora, but you could petition upstream to support python 2.3 if you think it's important. If upstream support python 2.3, so will Fedora.

Comment 22 Fedora Update System 2016-04-13 07:23:38 UTC
sshuttle-0.77.3-0.1.20160402git6e15e691.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.