Skip to content

Commit

Permalink
Merge branch 'master' into 112-int
Browse files Browse the repository at this point in the history
Conflicts:
	paramiko/win_pageant.py
  • Loading branch information
bitprophet committed Mar 19, 2013
2 parents 5f51374 + d5db603 commit a7ee250
Show file tree
Hide file tree
Showing 16 changed files with 344 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
build/
dist/
.tox/
paramiko.egg-info/
test.log
docs/
33 changes: 32 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,40 @@ Issues noted as "Fabric #NN" can be found at https://github.com/fabric/fabric/.
Releases
========

v1.10.0 (DD MM YYYY)
v1.11.0 (DD MM YYYY)
--------------------
* #100: Remove use of PyWin32 in `win_pageant` module. Module was already
dependent on ctypes for constructing appropriate structures and had ctypes
implementations of all functionality. Thanks to Jason R. Coombs for the
patch.

v1.10.0 (1st Mar 2013)
--------------------

* #66: Batch SFTP writes to help speed up file transfers. Thanks to Olle
Lundberg for the patch.
* #133: Fix handling of window-change events to be on-spec and not
attempt to wait for a response from the remote sshd; this fixes problems with
less common targets such as some Cisco devices. Thanks to Phillip Heller for
catch & patch.
* #93: Overhaul SSH config parsing to be in line with `man ssh_config` (& the
behavior of `ssh` itself), including addition of parameter expansion within
config values. Thanks to Olle Lundberg for the patch.
* #110: Honor SSH config `AddressFamily` setting when looking up local
host's FQDN. Thanks to John Hensley for the patch.
* #128: Defer FQDN resolution until needed, when parsing SSH config files.
Thanks to Parantapa Bhattacharya for catch & patch.
* #102: Forego random padding for packets when running under `*-ctr` ciphers.
This corrects some slowdowns on platforms where random byte generation is
inefficient (e.g. Windows). Thanks to `@warthog618` for catch & patch, and
Michael van der Kolff for code/technique review.
* #127: Turn `SFTPFile` into a context manager. Thanks to Michael Williamson
for the patch.
* #116: Limit `Message.get_bytes` to an upper bound of 1MB to protect against
potential DoS vectors. Thanks to `@mvschaik` for catch & patch.
* #115: Add convenience `get_pty` kwarg to `Client.exec_command` so users not
manually controlling a channel object can still toggle PTY creation. Thanks
to Michael van der Kolff for the patch.
* #71: Add `SFTPClient.putfo` and `.getfo` methods to allow direct
uploading/downloading of file-like objects. Thanks to Eric Buehl for the
patch.
Expand Down
20 changes: 3 additions & 17 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ paramiko

:Paramiko: Python SSH module
:Copyright: Copyright (c) 2003-2009 Robey Pointer <[email protected]>
:Copyright: Copyright (c) 2012 Jeff Forcier <[email protected]>
:Copyright: Copyright (c) 2013 Jeff Forcier <[email protected]>
:License: LGPL
:Homepage: https://github.com/paramiko/paramiko/

Expand All @@ -20,7 +20,7 @@ What
----

"paramiko" is a combination of the esperanto words for "paranoid" and
"friend". it's a module for python 2.2+ that implements the SSH2 protocol
"friend". it's a module for python 2.5+ that implements the SSH2 protocol
for secure (encrypted and authenticated) connections to remote machines.
unlike SSL (aka TLS), SSH2 protocol does not require hierarchical
certificates signed by a powerful central authority. you may know SSH2 as
Expand All @@ -39,8 +39,7 @@ that should have come with this archive.
Requirements
------------

- python 2.3 or better <http://www.python.org/>
(python 2.2 is also supported, but not recommended)
- python 2.5 or better <http://www.python.org/>
- pycrypto 2.1 or better <https://www.dlitz.net/software/pycrypto/>

If you have setuptools, you can build and install paramiko and all its
Expand All @@ -58,19 +57,6 @@ should also work on Windows, though i don't test it as frequently there.
if you run into Windows problems, send me a patch: portability is important
to me.

python 2.2 may work, thanks to some patches from Roger Binns. things to
watch out for:

* sockets in 2.2 don't support timeouts, so the 'select' module is
imported to do polling.
* logging is mostly stubbed out. it works just enough to let paramiko
create log files for debugging, if you want them. to get real logging,
you can backport python 2.3's logging package. Roger has done that
already:
http://sourceforge.net/project/showfiles.php?group_id=75211&package_id=113804

you really should upgrade to python 2.3. laziness is no excuse! :)

some python distributions don't include the utf-8 string encodings, for
reasons of space (misdirected as that is). if your distribution is
missing encodings, you'll see an error like this::
Expand Down
6 changes: 3 additions & 3 deletions paramiko/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

"""
I{Paramiko} (a combination of the esperanto words for "paranoid" and "friend")
is a module for python 2.3 or greater that implements the SSH2 protocol for
is a module for python 2.5 or greater that implements the SSH2 protocol for
secure (encrypted and authenticated) connections to remote machines. Unlike
SSL (aka TLS), the SSH2 protocol does not require hierarchical certificates
signed by a powerful central authority. You may know SSH2 as the protocol that
Expand Down Expand Up @@ -50,8 +50,8 @@

import sys

if sys.version_info < (2, 2):
raise RuntimeError('You need python 2.2 for this module.')
if sys.version_info < (2, 5):
raise RuntimeError('You need python 2.5+ for this module.')


__author__ = "Jeff Forcier <[email protected]>"
Expand Down
24 changes: 16 additions & 8 deletions paramiko/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def __repr__(self):
out += '>'
return out

def get_pty(self, term='vt100', width=80, height=24):
def get_pty(self, term='vt100', width=80, height=24, width_pixels=0,
height_pixels=0):
"""
Request a pseudo-terminal from the server. This is usually used right
after creating a client channel, to ask the server to provide some
Expand All @@ -136,6 +137,10 @@ def get_pty(self, term='vt100', width=80, height=24):
@type width: int
@param height: height (in characters) of the terminal screen
@type height: int
@param width_pixels: width (in pixels) of the terminal screen
@type width_pixels: int
@param height_pixels: height (in pixels) of the terminal screen
@type height_pixels: int
@raise SSHException: if the request was rejected or the channel was
closed
Expand All @@ -150,8 +155,8 @@ def get_pty(self, term='vt100', width=80, height=24):
m.add_string(term)
m.add_int(width)
m.add_int(height)
# pixel height, width (usually useless)
m.add_int(0).add_int(0)
m.add_int(width_pixels)
m.add_int(height_pixels)
m.add_string('')
self._event_pending()
self.transport._send_user_message(m)
Expand Down Expand Up @@ -239,7 +244,7 @@ def invoke_subsystem(self, subsystem):
self.transport._send_user_message(m)
self._wait_for_event()

def resize_pty(self, width=80, height=24):
def resize_pty(self, width=80, height=24, width_pixels=0, height_pixels=0):
"""
Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous L{get_pty} call.
Expand All @@ -248,6 +253,10 @@ def resize_pty(self, width=80, height=24):
@type width: int
@param height: new height (in characters) of the terminal screen
@type height: int
@param width_pixels: new width (in pixels) of the terminal screen
@type width_pixels: int
@param height_pixels: new height (in pixels) of the terminal screen
@type height_pixels: int
@raise SSHException: if the request was rejected or the channel was
closed
Expand All @@ -258,13 +267,12 @@ def resize_pty(self, width=80, height=24):
m.add_byte(chr(MSG_CHANNEL_REQUEST))
m.add_int(self.remote_chanid)
m.add_string('window-change')
m.add_boolean(True)
m.add_boolean(False)
m.add_int(width)
m.add_int(height)
m.add_int(0).add_int(0)
self._event_pending()
m.add_int(width_pixels)
m.add_int(height_pixels)
self.transport._send_user_message(m)
self._wait_for_event()

def exit_status_ready(self):
"""
Expand Down
13 changes: 10 additions & 3 deletions paramiko/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def close(self):
self._agent.close()
self._agent = None

def exec_command(self, command, bufsize=-1, timeout=None):
def exec_command(self, command, bufsize=-1, timeout=None, get_pty=False):
"""
Execute a command on the SSH server. A new L{Channel} is opened and
the requested command is executed. The command's input and output
Expand All @@ -368,14 +368,17 @@ def exec_command(self, command, bufsize=-1, timeout=None):
@raise SSHException: if the server fails to execute the command
"""
chan = self._transport.open_session()
if(get_pty):
chan.get_pty()
chan.settimeout(timeout)
chan.exec_command(command)
stdin = chan.makefile('wb', bufsize)
stdout = chan.makefile('rb', bufsize)
stderr = chan.makefile_stderr('rb', bufsize)
return stdin, stdout, stderr

def invoke_shell(self, term='vt100', width=80, height=24):
def invoke_shell(self, term='vt100', width=80, height=24, width_pixels=0,
height_pixels=0):
"""
Start an interactive shell session on the SSH server. A new L{Channel}
is opened and connected to a pseudo-terminal using the requested
Expand All @@ -387,13 +390,17 @@ def invoke_shell(self, term='vt100', width=80, height=24):
@type width: int
@param height: the height (in characters) of the terminal window
@type height: int
@param width_pixels: the width (in pixels) of the terminal window
@type width_pixels: int
@param height_pixels: the height (in pixels) of the terminal window
@type height_pixels: int
@return: a new channel connected to the remote shell
@rtype: L{Channel}
@raise SSHException: if the server fails to invoke a shell
"""
chan = self._transport.open_session()
chan.get_pty(term, width, height)
chan.get_pty(term, width, height, width_pixels, height_pixels)
chan.invoke_shell()
return chan

Expand Down
Loading

0 comments on commit a7ee250

Please sign in to comment.