clean up authentication
add new exception "BadAuthenticationType", which is raised when auth fails
because your auth type (password or public-key) isn't valid on the server.
used this as an excuse to clean up auth_password and auth_publickey so their
'event' arg is optional, and if missing, they block until auth is finished,
raising an exception on error.
also, don't close the session on failed auth -- the server may let you try
again.
added some test cases for failed auth.
symlink, readlink
add support for symlink command, and finish support for readlink. (i guess
i started readlink a while ago but forgot to add the right method to the
SFTPServerInterface class.)
add stderr support methods
big embarrassment: i didn't read the ssh2 docs close enough, and all this
time paramiko wasn't handling "extended_data" packets, which contain stderr
output.
so now, several new functions: recv_stderr_ready() and recv_stderr() to
mirror recv_ready() and recv(), and set_combined_stderr() to force stderr
to be combined into stdout. also, makefile_stderr() to create a fake file
object to represent stderr.
fix SFTPFile gettimeout/settimeout
i don't think the gettimeout/settimeout calls on SFTPFile ever worked.
also, simplify the implementation of _get_size() since it's nearly
identical to stat().
sftp server support!
finally check in sftp_handle (file handle abstraction), sftp_si (server
interface), and sftp_server (server implementation) -- all of which make
a roughly 90% implementation of server-side sftp.
add finish_subsystem()
when a SubsystemHandler is being decomissioned (the client has closed the
channel or transport, or the socket went away), make a callback to let the
handler do any shutdown it needs to.
fix extremely unlikely channel counter wrapping
Transport's channel counter can overflow after 4 billion some channels are
created. make it wrap back around after 16 million instead. also allow the
logging channel to be set manually. fix some comments elsewhere.
fix Transport.get_username() to work in server mode too
whenever i split the 'username' field into username and auth_username,
i guess that made get_username() stop working for server mode (because the
username was stored in a different field). this should fix it.
add key exchange tests + 1 more sftp test
add test suite for key-exchange protocols, since i apparently broke the
"gex" protocol recently and never noticed. also add an sftp unit test for
mkdir/rmdir.
don't forget demo_windows.py
update MANIFEST.in to include demo_windows.py and not include the demo
keys (they're in tests/ now). clean up the README to explain the demo
scripts better now, since there are so many of them. then fix up the
demo scripts to look in tests/ for the keys.
demo_windows.py doesn't need to call get_pty() (in fact, i think that's
blowing openssh's mind) and was executing the wrong command.
don't unlink a Channel until the server closes it too
when close()'ing a Channel, don't immediately unlink it from the Transport.
instead, wait for the server to send a close message.
this should fix a bug where doing close() on an EOF'd channel would cause
the entire transport to be killed, because the server would send an
'exit-status' and 'close' message for a channel that we no longer had a
record of.
better debugging, improve subsytem handler
add a list of ssh packet names for debugging. improve the server-mode
subsystem handler so it can take extra parameters (list or keyword) and
pass them to the subsystem constructor. remove a misleading comment
about rekeying (which was already implemented).
switch Transport.connect() to using a Pkey object for the host key
i suddenly realized that passing "hostkeytype" and "hostkey" as strings to
Transport.connect() was pretty silly since i went to all the effort of making
a class specifically for holding keys. so Transport.connect() now just takes
host-key argument: "hostkey" as a PKey object.
updated the demos to use PKey objects when reading the host key file, and to
use the new "hostkey" argument.
fix test.py to use options instead of env vars, sftp tests default off
fix up the test framework so that the sftp unit tests aren't always run (you
have to ask for them explicitly) and they take their configuration from
command-line options. they still require a remote server.
fix __init__
fix __init__ to export BufferedFile and randpool, and to catch up with the
changes from a week or 2 ago where sftp_attr & friends were split off.
add Message.rewind()
add rewind() method to Message, which just resets the pointer so you can
start reading from the beginning again. this is useful for some tests.
clean up pkey interface
change the pkey interface so that it's no longer possible to have a pkey
that doesn't represent a valid key. (ie: no more "blank" key objects.)
also add "get_bits" and "can_sign" methods to determine the key bit length
and whether it can sign things (contains the "private parts") respectively.
unit tests for Message
spanking new unit tests for Message. i'm trying to fix the embarrassment
of having so little of paramiko testable. next up is Transport!
add sftp.normalize
kevin c. dorff pointed out that it would be nice to expose a way to
determine the server's "current working directory", so this new method
(normalize) directly maps to REALPATH.
move SubsystemHandler to server.py
move SubsystemHandler into server.py where it makes more sense (it's part of
the server interface).
also fix up paramiko's "version string" used in ssh2 negotiation to stop
saying "pyssh" and start saying "paramiko". :)
Message.add() can take many args
a bit of cleanup to Message: add() can now take any number of params, and
will add them all in order (using type guessing).
fix rbuffer -> _rbuffer in 3 places i missed
fix 3 places where "rbuffer" hadn't been converted to "_rbuffer". thanks to
kevin c. dorff for the bug report.
add sftp_client.py
i retardedly forgot to import this file a few days ago: it's the split-out
client mode for sftp. it now also has some changes to adapt it to the
improved SFTPAttributes object API.
clean up SFTPAttributes
add english descriptions to the FX_* error codes of sftp. clean up (and
document) SFTPAttributes since it's exported now, and make it simple to
generate one from a python os.stat object. make "_pythonize" the default --
that is, just use the same field names as python does for os.stat. (i'm not
sure why i didn't do it that way in the first place; probably ignorance.)
also add str() method that converts the SFTPAttributes into a string suitable
for use in ls (used in an obscure way in sftp servers).
note pycrypto 2.0 in README
update the README to note that pycrypto 2.0 works (i just tried it). also
fix the name from pyCrypt back to pycrypto -- that project is having trouble
making up its mind about naming. :)