diff options
-rw-r--r-- | paramiko/buffered_pipe.py | 20 | ||||
-rw-r--r-- | paramiko/channel.py | 53 | ||||
-rw-r--r-- | paramiko/client.py | 7 | ||||
-rw-r--r-- | paramiko/kex_group14.py | 2 | ||||
-rw-r--r-- | paramiko/rsakey.py | 5 | ||||
-rw-r--r-- | paramiko/server.py | 60 | ||||
-rw-r--r-- | paramiko/sftp_handle.py | 15 | ||||
-rw-r--r-- | paramiko/transport.py | 86 | ||||
-rw-r--r-- | setup.cfg | 2 |
9 files changed, 160 insertions, 90 deletions
diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py index 605f51e9..9a65cd95 100644 --- a/paramiko/buffered_pipe.py +++ b/paramiko/buffered_pipe.py @@ -41,7 +41,7 @@ class BufferedPipe (object): file or socket, but is fed data from another thread. This is used by `.Channel`. """ - + def __init__(self): self._lock = threading.Lock() self._cv = threading.Condition(self._lock) @@ -67,7 +67,7 @@ class BufferedPipe (object): Set an event on this buffer. When data is ready to be read (or the buffer has been closed), the event will be set. When no data is ready, the event will be cleared. - + :param threading.Event event: the event to set/clear """ self._lock.acquire() @@ -84,12 +84,12 @@ class BufferedPipe (object): event.clear() finally: self._lock.release() - + def feed(self, data): """ Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done. - + :param data: the data to add, as a `str` or `bytes` """ self._lock.acquire() @@ -106,7 +106,7 @@ class BufferedPipe (object): Returns true if data is buffered and ready to be read from this feeder. A ``False`` result does not mean that the feeder has closed; it means you may need to wait before more data arrives. - + :return: ``True`` if a `read` call would immediately return at least one byte; ``False`` otherwise. @@ -135,7 +135,7 @@ class BufferedPipe (object): :param float timeout: maximum seconds to wait (or ``None``, the default, to wait forever) :return: the read data, as a `bytes` - + :raises PipeTimeout: if a timeout was specified and no data was ready before that timeout @@ -172,11 +172,11 @@ class BufferedPipe (object): self._lock.release() return out - + def empty(self): """ Clear out the buffer and return all data that was in it. - + :return: any data that was in the buffer prior to clearing it out, as a `str` @@ -190,7 +190,7 @@ class BufferedPipe (object): return out finally: self._lock.release() - + def close(self): """ Close this pipe object. Future calls to `read` after the buffer @@ -208,7 +208,7 @@ class BufferedPipe (object): def __len__(self): """ Return the number of bytes buffered. - + :return: number (`int`) of bytes buffered """ self._lock.acquire() diff --git a/paramiko/channel.py b/paramiko/channel.py index f67ed7e2..ed03a813 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -419,7 +419,8 @@ class Channel (ClosingContextManager): :param function handler: a required handler to use for incoming SSH Agent connections - :return: True if we are ok, else False (at that time we always return ok) + :return: True if we are ok, else False + (at that time we always return ok) :raises: SSHException in case of channel problem. """ @@ -603,8 +604,8 @@ class Channel (ClosingContextManager): """ Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be - received at once is specified by ``nbytes``. If a string of length zero - is returned, the channel stream has closed. + received at once is specified by ``nbytes``. If a string of + length zero is returned, the channel stream has closed. :param int nbytes: maximum number of bytes to read. :return: received data, as a `bytes` @@ -754,7 +755,7 @@ class Channel (ClosingContextManager): if sending stalled for longer than the timeout set by `settimeout`. :raises socket.error: if an error occurred before the entire string was sent. - + .. note:: If the channel is closed while only part of the data has been sent, there is no way to determine how much data (if any) was sent. @@ -778,7 +779,7 @@ class Channel (ClosingContextManager): if sending stalled for longer than the timeout set by `settimeout`. :raises socket.error: if an error occurred before the entire string was sent. - + .. versionadded:: 1.1 """ while s: @@ -896,7 +897,7 @@ class Channel (ClosingContextManager): # attribute instead of a semipublic .closed attribute. return self.closed - ### calls from Transport + # ...calls from Transport def _set_transport(self, transport): self.transport = transport @@ -905,7 +906,8 @@ class Channel (ClosingContextManager): def _set_window(self, window_size, max_packet_size): self.in_window_size = window_size self.in_max_packet_size = max_packet_size - # threshold of bytes we receive before we bother to send a window update + # threshold of bytes we receive before we bother to send + # a window update self.in_window_threshold = window_size // 10 self.in_window_sofar = 0 self._log(DEBUG, 'Max packet in: %d bytes' % max_packet_size) @@ -946,7 +948,10 @@ class Channel (ClosingContextManager): code = m.get_int() s = m.get_binary() if code != 1: - self._log(ERROR, 'unknown extended_data type %d; discarding' % code) + self._log( + ERROR, + 'unknown extended_data type %d; discarding' % code + ) return if self.combine_stderr: self._feed(s) @@ -986,8 +991,15 @@ class Channel (ClosingContextManager): if server is None: ok = False else: - ok = server.check_channel_pty_request(self, term, width, height, pixelwidth, - pixelheight, modes) + ok = server.check_channel_pty_request( + self, + term, + width, + height, + pixelwidth, + pixelheight, + modes + ) elif key == 'shell': if server is None: ok = False @@ -1020,8 +1032,8 @@ class Channel (ClosingContextManager): if server is None: ok = False else: - ok = server.check_channel_window_change_request(self, width, height, pixelwidth, - pixelheight) + ok = server.check_channel_window_change_request( + self, width, height, pixelwidth, pixelheight) elif key == 'x11-req': single_connection = m.get_boolean() auth_proto = m.get_text() @@ -1030,8 +1042,13 @@ class Channel (ClosingContextManager): if server is None: ok = False else: - ok = server.check_channel_x11_request(self, single_connection, - auth_proto, auth_cookie, screen_number) + ok = server.check_channel_x11_request( + self, + single_connection, + auth_proto, + auth_cookie, + screen_number + ) elif key == 'auth-agent-req@openssh.com': if server is None: ok = False @@ -1073,7 +1090,7 @@ class Channel (ClosingContextManager): if m is not None: self.transport._send_user_message(m) - ### internals... + # ...internals... def _send(self, s, m): size = len(s) @@ -1149,7 +1166,8 @@ class Channel (ClosingContextManager): return m1, m2 def _unlink(self): - # server connection could die before we become active: still signal the close! + # server connection could die before we become active: + # still signal the close! if self.closed: return self.lock.acquire() @@ -1192,7 +1210,8 @@ class Channel (ClosingContextManager): # should we block? if self.timeout == 0.0: raise socket.timeout() - # loop here in case we get woken up but a different thread has filled the buffer + # loop here in case we get woken up but a different thread has + # filled the buffer timeout = self.timeout while self.out_window_size == 0: if self.closed or self.eof_sent: diff --git a/paramiko/client.py b/paramiko/client.py index 3bb78e9f..bbda1f80 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -142,7 +142,8 @@ class SSHClient (ClosingContextManager): with open(filename, 'w') as f: for hostname, keys in self._host_keys.items(): for keytype, key in keys.items(): - f.write('%s %s %s\n' % (hostname, keytype, key.get_base64())) + f.write('%s %s %s\n' % ( + hostname, keytype, key.get_base64())) def get_host_keys(self): """ @@ -354,8 +355,8 @@ class SSHClient (ClosingContextManager): # host key, because the host is authenticated via GSS-API / SSPI as # well as our client. if not self._transport.use_gss_kex: - our_server_key = self._system_host_keys.get(server_hostkey_name, - {}).get(keytype, None) + our_server_key = self._system_host_keys.get( + server_hostkey_name, {}).get(keytype) if our_server_key is None: our_server_key = self._host_keys.get(server_hostkey_name, {}).get(keytype, None) diff --git a/paramiko/kex_group14.py b/paramiko/kex_group14.py index 9f7dd216..22955e34 100644 --- a/paramiko/kex_group14.py +++ b/paramiko/kex_group14.py @@ -28,7 +28,7 @@ from hashlib import sha1 class KexGroup14(KexGroup1): # http://tools.ietf.org/html/rfc3526#section-3 - P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF + P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF # noqa G = 2 name = 'diffie-hellman-group14-sha1' diff --git a/paramiko/rsakey.py b/paramiko/rsakey.py index fa2b4c44..8ccf4c30 100644 --- a/paramiko/rsakey.py +++ b/paramiko/rsakey.py @@ -37,7 +37,8 @@ class RSAKey(PKey): data. """ - def __init__(self, msg=None, data=None, filename=None, password=None, key=None, file_obj=None): + def __init__(self, msg=None, data=None, filename=None, password=None, + key=None, file_obj=None): self.key = None if file_obj is not None: self._from_private_key(file_obj, password) @@ -167,7 +168,7 @@ class RSAKey(PKey): ) return RSAKey(key=key) - ### internals... + # ...internals... def _from_private_key_file(self, filename, password): data = self._read_private_key_file('RSA', filename, password) diff --git a/paramiko/server.py b/paramiko/server.py index bc4ac071..da4a1e1c 100644 --- a/paramiko/server.py +++ b/paramiko/server.py @@ -22,7 +22,8 @@ import threading from paramiko import util -from paramiko.common import DEBUG, ERROR, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, AUTH_FAILED, AUTH_SUCCESSFUL +from paramiko.common import DEBUG, ERROR, \ + OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, AUTH_FAILED, AUTH_SUCCESSFUL from paramiko.py3compat import string_types @@ -250,9 +251,10 @@ class ServerInterface (object): We don't check if the krb5 principal is allowed to log in on the server, because there is no way to do that in python. So if you develop your own SSH server with paramiko for a cetain - plattform like Linux, you should call C{krb5_kuserok()} in your - local kerberos library to make sure that the krb5_principal has - an account on the server and is allowed to log in as a user. + plattform like Linux, you should call C{krb5_kuserok()} in + your local kerberos library to make sure that the + krb5_principal has an account on the server and is allowed to + log in as a user. :see: `http://www.unix.com/man-page/all/3/krb5_kuserok/` """ if gss_authenticated == AUTH_SUCCESSFUL: @@ -281,9 +283,10 @@ class ServerInterface (object): We don't check if the krb5 principal is allowed to log in on the server, because there is no way to do that in python. So if you develop your own SSH server with paramiko for a cetain - plattform like Linux, you should call C{krb5_kuserok()} in your - local kerberos library to make sure that the krb5_principal has - an account on the server and is allowed to log in as a user. + plattform like Linux, you should call C{krb5_kuserok()} in + your local kerberos library to make sure that the + krb5_principal has an account on the server and is allowed + to log in as a user. :see: `http://www.unix.com/man-page/all/3/krb5_kuserok/` """ if gss_authenticated == AUTH_SUCCESSFUL: @@ -366,10 +369,11 @@ class ServerInterface (object): """ return False - ### Channel requests + # ...Channel requests... - def check_channel_pty_request(self, channel, term, width, height, pixelwidth, pixelheight, - modes): + def check_channel_pty_request( + self, channel, term, width, height, pixelwidth, pixelheight, + modes): """ Determine if a pseudo-terminal of the given dimensions (usually requested for shell access) can be provided on the given channel. @@ -447,14 +451,16 @@ class ServerInterface (object): ``True`` if this channel is now hooked up to the requested subsystem; ``False`` if that subsystem can't or won't be provided. """ - handler_class, larg, kwarg = channel.get_transport()._get_subsystem_handler(name) + handler_class, larg, kwarg = \ + channel.get_transport()._get_subsystem_handler(name) if handler_class is None: return False handler = handler_class(channel, name, self, *larg, **kwarg) handler.start() return True - def check_channel_window_change_request(self, channel, width, height, pixelwidth, pixelheight): + def check_channel_window_change_request( + self, channel, width, height, pixelwidth, pixelheight): """ Determine if the pseudo-terminal on the given channel can be resized. This only makes sense if a pty was previously allocated on it. @@ -472,7 +478,9 @@ class ServerInterface (object): """ return False - def check_channel_x11_request(self, channel, single_connection, auth_protocol, auth_cookie, screen_number): + def check_channel_x11_request( + self, channel, single_connection, auth_protocol, auth_cookie, + screen_number): """ Determine if the client will be provided with an X11 session. If this method returns ``True``, X11 applications should be routed through new @@ -588,12 +596,12 @@ class InteractiveQuery (object): self.add_prompt(x) else: self.add_prompt(x[0], x[1]) - + def add_prompt(self, prompt, echo=True): """ Add a prompt to this query. The prompt should be a (reasonably short) string. Multiple prompts can be added to the same query. - + :param str prompt: the user prompt :param bool echo: ``True`` (default) if the user's response should be echoed; @@ -621,10 +629,11 @@ class SubsystemHandler (threading.Thread): Create a new handler for a channel. This is used by `.ServerInterface` to start up a new handler when a channel requests this subsystem. You don't need to override this method, but if you do, be sure to pass the - ``channel`` and ``name`` parameters through to the original ``__init__`` - method here. + ``channel`` and ``name`` parameters through to the original + ``__init__`` method here. - :param .Channel channel: the channel associated with this subsystem request. + :param .Channel channel: the channel associated with this + subsystem request. :param str name: name of the requested subsystem. :param .ServerInterface server: the server object for the session that started this subsystem @@ -634,7 +643,7 @@ class SubsystemHandler (threading.Thread): self.__transport = channel.get_transport() self.__name = name self.__server = server - + def get_server(self): """ Return the `.ServerInterface` object associated with this channel and @@ -644,10 +653,12 @@ class SubsystemHandler (threading.Thread): def _run(self): try: - self.__transport._log(DEBUG, 'Starting handler for subsystem %s' % self.__name) + self.__transport._log( + DEBUG, 'Starting handler for subsystem %s' % self.__name) self.start_subsystem(self.__name, self.__transport, self.__channel) except Exception as e: - self.__transport._log(ERROR, 'Exception in subsystem handler for "%s": %s' % + self.__transport._log( + ERROR, 'Exception in subsystem handler for "%s": %s' % (self.__name, str(e))) self.__transport._log(ERROR, util.tb_strings()) try: @@ -663,8 +674,8 @@ class SubsystemHandler (threading.Thread): subsystem is finished, this method will return. After this method returns, the channel is closed. - The combination of ``transport`` and ``channel`` are unique; this handler - corresponds to exactly one `.Channel` on one `.Transport`. + The combination of ``transport`` and ``channel`` are unique; this + handler corresponds to exactly one `.Channel` on one `.Transport`. .. note:: It is the responsibility of this method to exit if the underlying @@ -676,7 +687,8 @@ class SubsystemHandler (threading.Thread): :param str name: name of the requested subsystem. :param .Transport transport: the server-mode `.Transport`. - :param .Channel channel: the channel associated with this subsystem request. + :param .Channel channel: the channel associated with this subsystem + request. """ pass diff --git a/paramiko/sftp_handle.py b/paramiko/sftp_handle.py index 05b5e904..bcb4bcba 100644 --- a/paramiko/sftp_handle.py +++ b/paramiko/sftp_handle.py @@ -30,10 +30,10 @@ class SFTPHandle (ClosingContextManager): Abstract object representing a handle to an open file (or folder) in an SFTP server implementation. Each handle has a string representation used by the client to refer to the underlying file. - + Server implementations can (and should) subclass SFTPHandle to implement features of a file handle, like `stat` or `chattr`. - + Instances of this class may be used as context managers. """ def __init__(self, flags=0): @@ -41,8 +41,9 @@ class SFTPHandle (ClosingContextManager): Create a new file handle representing a local file being served over SFTP. If ``flags`` is passed in, it's used to determine if the file is open in append mode. - - :param int flags: optional flags as passed to `.SFTPServerInterface.open` + + :param int flags: optional flags as passed to + `.SFTPServerInterface.open` """ self.__flags = flags self.__name = None @@ -55,7 +56,7 @@ class SFTPHandle (ClosingContextManager): When a client closes a file, this method is called on the handle. Normally you would use this method to close the underlying OS level file object(s). - + The default implementation checks for attributes on ``self`` named ``readfile`` and/or ``writefile``, and if either or both are present, their ``close()`` methods are called. This means that if you are @@ -117,7 +118,7 @@ class SFTPHandle (ClosingContextManager): differently from ``readfile`` to make it easy to implement read-only (or write-only) files, but if both attributes are present, they should refer to the same file. - + :param offset: position in the file to start reading from. :type offset: int or long :param str data: data to write into the file. @@ -167,7 +168,7 @@ class SFTPHandle (ClosingContextManager): """ return SFTP_OP_UNSUPPORTED - ### internals... + # ...internals... def _set_files(self, files): """ diff --git a/paramiko/transport.py b/paramiko/transport.py index 6d7dd0e8..914166d7 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -1806,7 +1806,6 @@ class Transport (threading.Thread, ClosingContextManager): self.saved_exception = e except EOFError as e: self._log(DEBUG, 'EOF in transport thread') - #self._log(DEBUG, util.tb_strings()) self.saved_exception = e except socket.error as e: if type(e.args) is tuple: @@ -2070,7 +2069,8 @@ class Transport (threading.Thread, ClosingContextManager): self.remote_kex_init = cMSG_KEXINIT + m.get_so_far() def _activate_inbound(self): - """switch on newly negotiated encryption parameters for inbound traffic""" + """switch on newly negotiated encryption parameters for + inbound traffic""" block_size = self._cipher_info[self.remote_cipher]['block-size'] if self.server_mode: IV_in = self._compute_key('A', block_size) @@ -2094,18 +2094,22 @@ class Transport (threading.Thread, ClosingContextManager): self.packetizer.set_inbound_compressor(compress_in()) def _activate_outbound(self): - """switch on newly negotiated encryption parameters for outbound traffic""" + """switch on newly negotiated encryption parameters for + outbound traffic""" m = Message() m.add_byte(cMSG_NEWKEYS) self._send_message(m) block_size = self._cipher_info[self.local_cipher]['block-size'] if self.server_mode: IV_out = self._compute_key('B', block_size) - key_out = self._compute_key('D', self._cipher_info[self.local_cipher]['key-size']) + key_out = self._compute_key( + 'D', self._cipher_info[self.local_cipher]['key-size']) else: IV_out = self._compute_key('A', block_size) - key_out = self._compute_key('C', self._cipher_info[self.local_cipher]['key-size']) - engine = self._get_cipher(self.local_cipher, key_out, IV_out, self._ENCRYPT) + key_out = self._compute_key( + 'C', self._cipher_info[self.local_cipher]['key-size']) + engine = self._get_cipher( + self.local_cipher, key_out, IV_out, self._ENCRYPT) mac_size = self._mac_info[self.local_mac]['size'] mac_engine = self._mac_info[self.local_mac]['class'] # initial mac keys are done in the hash's natural size (not the @@ -2115,9 +2119,11 @@ class Transport (threading.Thread, ClosingContextManager): else: mac_key = self._compute_key('E', mac_engine().digest_size) sdctr = self.local_cipher.endswith('-ctr') - self.packetizer.set_outbound_cipher(engine, block_size, mac_engine, mac_size, mac_key, sdctr) + self.packetizer.set_outbound_cipher( + engine, block_size, mac_engine, mac_size, mac_key, sdctr) compress_out = self._compression_info[self.local_compression][0] - if (compress_out is not None) and ((self.local_compression != 'zlib@openssh.com') or self.authenticated): + if (compress_out is not None) and \ + ((self.local_compression != 'zlib@openssh.com') or self.authenticated): self._log(DEBUG, 'Switching on outbound compression ...') self.packetizer.set_outbound_compressor(compress_out()) if not self.packetizer.need_rekey(): @@ -2173,7 +2179,10 @@ class Transport (threading.Thread, ClosingContextManager): self._log(DEBUG, 'Received global request "%s"' % kind) want_reply = m.get_boolean() if not self.server_mode: - self._log(DEBUG, 'Rejecting "%s" global request from server.' % kind) + self._log( + DEBUG, + 'Rejecting "%s" global request from server.' % kind + ) ok = False elif kind == 'tcpip-forward': address = m.get_text() @@ -2224,7 +2233,8 @@ class Transport (threading.Thread, ClosingContextManager): return self.lock.acquire() try: - chan._set_remote_channel(server_chanid, server_window_size, server_max_packet_size) + chan._set_remote_channel( + server_chanid, server_window_size, server_max_packet_size) self._log(DEBUG, 'Secsh channel %d opened.' % chanid) if chanid in self.channel_events: self.channel_events[chanid].set() @@ -2237,9 +2247,13 @@ class Transport (threading.Thread, ClosingContextManager): chanid = m.get_int() reason = m.get_int() reason_str = m.get_text() - lang = m.get_text() + m.get_text() # ignored language reason_text = CONNECTION_FAILED_CODE.get(reason, '(unknown code)') - self._log(ERROR, 'Secsh channel %d open FAILED: %s: %s' % (chanid, reason_str, reason_text)) + self._log( + ERROR, + 'Secsh channel %d open FAILED: %s: %s' % ( + chanid, reason_str, reason_text) + ) self.lock.acquire() try: self.saved_exception = ChannelException(reason, reason_text) @@ -2258,7 +2272,8 @@ class Transport (threading.Thread, ClosingContextManager): initial_window_size = m.get_int() max_packet_size = m.get_int() reject = False - if (kind == 'auth-agent@openssh.com') and (self._forward_agent_handler is not None): + if (kind == 'auth-agent@openssh.com') and \ + (self._forward_agent_handler is not None): self._log(DEBUG, 'Incoming forward agent connection') self.lock.acquire() try: @@ -2268,7 +2283,11 @@ class Transport (threading.Thread, ClosingContextManager): elif (kind == 'x11') and (self._x11_handler is not None): origin_addr = m.get_text() origin_port = m.get_int() - self._log(DEBUG, 'Incoming x11 connection from %s:%d' % (origin_addr, origin_port)) + self._log( + DEBUG, + 'Incoming x11 connection from %s:%d' % ( + origin_addr, origin_port) + ) self.lock.acquire() try: my_chanid = self._next_channel() @@ -2279,14 +2298,20 @@ class Transport (threading.Thread, ClosingContextManager): server_port = m.get_int() origin_addr = m.get_text() origin_port = m.get_int() - self._log(DEBUG, 'Incoming tcp forwarded connection from %s:%d' % (origin_addr, origin_port)) + self._log( + DEBUG, + 'Incoming tcp forwarded connection from %s:%d' % ( + origin_addr, origin_port) + ) self.lock.acquire() try: my_chanid = self._next_channel() finally: self.lock.release() elif not self.server_mode: - self._log(DEBUG, 'Rejecting "%s" channel request from server.' % kind) + self._log( + DEBUG, + 'Rejecting "%s" channel request from server.' % kind) reject = True reason = OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED else: @@ -2302,11 +2327,17 @@ class Transport (threading.Thread, ClosingContextManager): origin_addr = m.get_text() origin_port = m.get_int() reason = self.server_object.check_channel_direct_tcpip_request( - my_chanid, (origin_addr, origin_port), (dest_addr, dest_port)) + my_chanid, + (origin_addr, origin_port), + (dest_addr, dest_port) + ) else: - reason = self.server_object.check_channel_request(kind, my_chanid) + reason = self.server_object.check_channel_request( + kind, my_chanid) if reason != OPEN_SUCCEEDED: - self._log(DEBUG, 'Rejecting "%s" channel request from client.' % kind) + self._log( + DEBUG, + 'Rejecting "%s" channel request from client.' % kind) reject = True if reject: msg = Message() @@ -2324,8 +2355,10 @@ class Transport (threading.Thread, ClosingContextManager): self._channels.put(my_chanid, chan) self.channels_seen[my_chanid] = True chan._set_transport(self) - chan._set_window(self.default_window_size, self.default_max_packet_size) - chan._set_remote_channel(chanid, initial_window_size, max_packet_size) + chan._set_window( + self.default_window_size, self.default_max_packet_size) + chan._set_remote_channel( + chanid, initial_window_size, max_packet_size) finally: self.lock.release() m = Message() @@ -2342,14 +2375,18 @@ class Transport (threading.Thread, ClosingContextManager): self._x11_handler(chan, (origin_addr, origin_port)) elif kind == 'forwarded-tcpip': chan.origin_addr = (origin_addr, origin_port) - self._tcp_handler(chan, (origin_addr, origin_port), (server_addr, server_port)) + self._tcp_handler( + chan, + (origin_addr, origin_port), + (server_addr, server_port) + ) else: self._queue_incoming_channel(chan) def _parse_debug(self, m): - always_display = m.get_boolean() + m.get_boolean() # always_display msg = m.get_string() - lang = m.get_string() + m.get_string() # language self._log(DEBUG, 'Debug msg: {0}'.format(util.safe_string(msg))) def _get_subsystem_handler(self, name): @@ -2396,7 +2433,6 @@ class SecurityOptions (object): ``ValueError`` will be raised. If you try to assign something besides a tuple to one of the fields, ``TypeError`` will be raised. """ - #__slots__ = [ 'ciphers', 'digests', 'key_types', 'kex', 'compression', '_transport' ] __slots__ = '_transport' def __init__(self, transport): @@ -5,6 +5,6 @@ universal = 1 omit = paramiko/_winapi.py [flake8] -exclude = sites,.git,build,dist,alt_env,appveyor,demos,tests,test.py +exclude = sites,.git,build,dist,alt_env,appveyor,demos,tests,test.py,transport.py ignore = E124,E125,E128,E261,E301,E302,E303,E402 max-line-length = 79 |