Re: [Twisted-Python] Negative error code breaks twisted.conch

2019-01-15 Thread Peter Westlake
Thank you!

Filed: https://twistedmatrix.com/trac/ticket/9573

I'll go off and read about submitting a fix now.

Peter.

On Tue, 15 Jan 2019, at 07:41, Glyph wrote:
> 
> 
>> On Jan 14, 2019, at 7:23 AM, Peter Westlake
>>  wrote:>> 
>> An SSCCE:
>> 
>> from twisted.internet import error
>> from twisted.python import failure
>> from twisted.conch.ssh.session import SSHSessionProcessProtocol
>> from mock import MagicMock
>> 
>> err = error.ProcessTerminated(-1)
>> fail = failure.Failure(err)
>> session = MagicMock()
>> proto = SSHSessionProcessProtocol(session)
>> proto.processEnded(fail)
>> 
>> 
>> That fails with:
>> 
>> Traceback (most recent call last):
>>   File ".../negexit.py", line 10, in 
>> proto.processEnded(fail)
>>   File "/usr/lib64/python2.7/site-
>>   packages/twisted/conch/ssh/session.py", line 279, in processEnded>> 
>> struct.pack('>L', err.exitCode))
>> struct.error: integer out of range for 'L' format code
>> 
>> I'm running an SSH server on Windows, where negative exit codes can
>> happen.>> 
>> Passing negative numbers to a ">L" format was allowed in Python
>> before 2.6, where the number was treated as an unsigned int of the
>> same bit pattern. It was deprecated in 2.6, and became an error in
>> 2.7. It's only just become a problem for me because I'm updating a 10
>> year old SSH server that has been running under 2.4 all this time.>> 
>> Presumably the fix is to bit-mask the exitCode? I was able to work
>> around the error by doing that in a copy of _dumbwin32proc.py which
>> was copied into the project (historical reasons, don't ask) but it
>> would be nice to have a proper upstream fix. Not least because I want
>> to purge the copied-in file, as you can imagine.> This is a great bug!  
>> Thanks for raising it.  Sounds like the fix is
> to simply reinterpret it as unsigned.
> https://en.wikipedia.org/wiki/Exit_status#Windows:> 
 Windows uses 32-bit unsigned integers as exit codes,[11] although
 the command interpreter treats them as signed.[12] If a process
 fails initialization, a Windows system error code may be
 returned.[13][14]> 
> Please do submit this fix upstream (file a ticket on Trac, open a PR,
> etc), it seems like one of the easier ones to integrate :-).> 
> -g
> _
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] txtorcon 19.0.0

2019-01-15 Thread meejah

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

I'm happy to announce txtorcon 19.0.0, containing the following
changes:

 * add TorControlProtocol.when_disconnected (will replace .on_disconnect)
 * add detach= kwarg to Tor.create_onion_service
 * add purpose= kwarg to TorState.build_circuit

You can download the release from PyPI or GitHub (or of
course "pip install txtorcon"):

   https://pypi.python.org/pypi/txtorcon/19.0.0
   https://github.com/meejah/txtorcon/releases/tag/v19.0.0

Releases are also available from the hidden service:

   http://timaq4ygg2iegci7.onion/txtorcon-19.0.0.tar.gz
   http://timaq4ygg2iegci7.onion/txtorcon-19.0.0.tar.gz.asc

Or via a "version 3" service:

   
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon-19.0.0.tar.gz
   
http://fjblvrw2jrxnhtg67qpbzi45r7ofojaoo3orzykesly2j3c2m3htapid.onion/txtorcon-19.0.0.tar.gz.asc

You can verify the sha256sum of both by running the following 4 lines
in a shell wherever you have the files downloaded:

cat