fix sending of large sftp packet sizes
fix a bug where packets larger than about 12KB would cause the session to
die on platforms other than osx. turns out that on most platforms, setting a
socket timeout also causes timeouts to occur on writes (but not on osx). so
on a huge write, once the os buffers were full, paramiko would get a
socket.timeout exception when writing, and bail.
since the timeout is primarily so we can periodically poll to see if the
session has been killed from elsewhere, do that on a timeout but otherwise
continue trying to write. large packet sizes (in sftp) should now work.
tweak sftp_file write behavior on large blocks of data
BufferedFile.write() wasn't correctly dealing with the possibility that the
underlying write might not write the entire data block at once (even though
the docs said it would). now that it's working, make sftp_file take
advantage of it in order to chop up blocks larger than 32kB (the max allowed
on sftp) and add a unit test for it.
fix race in transport thread startup
set active=True from the methods that start the main transport thread, right
before actually starting the thread. this avoids a race where the main
thread could be started, but the original thread could wake up from the
event.wait(0.1) before the new thread actually set the transport active.
impossible, you say? no machines so slow exist? au contraire, my sad
little linux box faced this problem earlier today.
when combining stderr with stdout on a channel, merge the buffers too
when turning on combine-stderr mode on a channel, grab the channel lock and
feed any existing stderr buffer into the normal buffer. this should help
applications (and my unit tests) avoid races between data coming in over
stderr and setting combine-stderr.
_send_eof is now slightly safer too, although i don't think that really fixed
anything. it just makes me feel better.
add thread ids to logs
add a logging filter that reports the thread-id of the logger, and use
that for all paramiko logging. since thread-local stuff didn't appear
until python 2.4, i hacked up my own little version to assign incrementing
numbers to threads as they log.
add methods for sending/receiving a channel's exit status
track a channel's exit status and provide a method (recv_exit_status) to
block waiting for it to arrive. also provide a convenience method for
servers to send it (send_exit_status). add shutdown_read and shutdown_write.
fix a bug in sending window change requests.
misc logging fixes
change the level of some log messages so interesting stuff gets logged at
info instead of debug. fix an oops where channels defaulted to being in
ultra debug mode, and make this mode depend on a new Transport method:
"set_hexdump".
more flexible logging
some tweaks to make channels etc follow the logger setting of their parent
transport, so that setting the log channel for a paramiko transport will
cause all sub-logging to branch out from that channel.
also, close all open file handles when the sftp server ends.
make loopback sftp tests the default
change the unit tests to default to always running the sftp tests locally,
and make a -R option to force the tests to run against a remote server.
the tests seem to work fine locally, and it helps test out server mode,
even though there's a danger that they could get isolated from reality
and only test that paramiko can talk to itself.
added listdir_attr()
add SFTPClient.listdir_attr() to fetch a list of files & their attributes,
instead of just their filenames. artur piwko would find this useful.
loopback sftp test
add ability to turn off more tests, and a secret (for now) -X option to do
the sftp tests via loopback socket. added another symlink sftp test to see
what happens with absolute symlinks.
cleanup & docs in sftp
add some more docs to SFTPHandle, and give a default implementation for
close() that's usually right. add a flush() to the default implementation
of write(). document that symlink's args in the sftp protocol are out of
order (the spec is wrong).
server support for stderr & exec_command
for the server side of my stderr blunder, add send_stderr & sendall_stderr,
and make the sending side of makefile_stderr work correctly.
also, call check_channel_exec_request on a server object for exec requests
on a channel.
add client-side multi-part auth support
added support for multi-part authentication (even though nobody supports it
that i've seen). on a successful "partial" auth, the auth_* method will
return a list of acceptable means to continue authenticating.
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.