andrikoz / parallel-ssh

Automatically exported from code.google.com/p/parallel-ssh
Other
0 stars 0 forks source link

Crash on Archlinux/Python3.4 when asking for password (Includes one line fix) #99

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run pssh on Archlinux which uses python 3.4
2. Use the -A argument to have it ask for a password
3. Stare blindly at the stacktrace when it crashes

What is the expected output?
[1] 15:47:51 [SUCCESS] 20.0.0.8
And not to crash

What do you see instead?
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
Traceback (most recent call last):
  File "/usr/bin/pssh", line 118, in <module>
    do_pssh(hosts, cmdline, opts)
  File "/usr/bin/pssh", line 89, in do_pssh
    statuses = manager.run()
  File "/usr/lib/python3.4/site-packages/psshlib/manager.py", line 74, in run
    self.iomap.poll(wait)
  File "/usr/lib/python3.4/site-packages/psshlib/manager.py", line 255, in poll
    handler(fd, self)
  File "/usr/lib/python3.4/site-packages/psshlib/askpass_server.py", line 72, in handle_write
    bytes_written = conn.send(buffer)
TypeError: 'str' does not support the buffer interface

What version of the product are you using? On what operating system?
> pssh --version
2.3.1
> uname -a
Linux 3.14.1-1-ARCH #1 SMP PREEMPT Mon Apr 14 20:40:47 CEST 2014 x86_64 
GNU/Linux
> python --version
Python 3.4.0

Please provide any additional information below.
How to fix:
Edit: /usr/lib/python3.4/site-packages/psshlib/askpass_server.py
Find line 72: bytes_written = conn.send(buffer)
Add ".encode('UTF-8')" to "buffer" so it looks like this: bytes_written = 
conn.send(buffer.encode('UTF-8'))

Stackoverflow post I found via google that explained what the problem was: 
http://stackoverflow.com/questions/5471158/typeerror-str-does-not-support-the-bu
ffer-interface

Original issue reported on code.google.com by adaml...@currencysolutions.com on 16 May 2014 at 2:49

GoogleCodeExporter commented 8 years ago
Same here (gentoo Linux, Python 3.4.2). Maybe it's better in general code to 
omit the encoding, using the default ('utf-8'). The following works nicely here:
 bytes_written = conn.send(buffer.encode())

Original comment by Bernd.Fe...@gmail.com on 14 Jan 2015 at 4:56