[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-141]
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".
This commit is contained in:
parent
8878a5f3c2
commit
c1ed20c4af
|
@ -326,7 +326,7 @@ class Transport (BaseTransport):
|
|||
self._disconnect_service_not_available()
|
||||
return
|
||||
if (self.auth_username is not None) and (self.auth_username != username):
|
||||
self._log(DEBUG, 'Auth rejected because the client attempted to change username in mid-flight')
|
||||
self._log(WARNING, 'Auth rejected because the client attempted to change username in mid-flight')
|
||||
self._disconnect_no_more_auth()
|
||||
return
|
||||
self.auth_username = username
|
||||
|
@ -351,10 +351,10 @@ class Transport (BaseTransport):
|
|||
try:
|
||||
key = self._key_info[keytype](Message(keyblob))
|
||||
except SSHException, e:
|
||||
self._log(DEBUG, 'Auth rejected: public key: %s' % str(e))
|
||||
self._log(INFO, 'Auth rejected: public key: %s' % str(e))
|
||||
key = None
|
||||
except:
|
||||
self._log(DEBUG, 'Auth rejected: unsupported or mangled public key')
|
||||
self._log(INFO, 'Auth rejected: unsupported or mangled public key')
|
||||
key = None
|
||||
if key is None:
|
||||
self._disconnect_no_more_auth()
|
||||
|
@ -375,18 +375,18 @@ class Transport (BaseTransport):
|
|||
sig = Message(m.get_string())
|
||||
blob = self._get_session_blob(key, service, username)
|
||||
if not key.verify_ssh_sig(blob, sig):
|
||||
self._log(DEBUG, 'Auth rejected: invalid signature')
|
||||
self._log(INFO, 'Auth rejected: invalid signature')
|
||||
result = AUTH_FAILED
|
||||
else:
|
||||
result = self.server_object.check_auth_none(username)
|
||||
# okay, send result
|
||||
m = Message()
|
||||
if result == AUTH_SUCCESSFUL:
|
||||
self._log(DEBUG, 'Auth granted.')
|
||||
self._log(INFO, 'Auth granted (%s).' % method)
|
||||
m.add_byte(chr(MSG_USERAUTH_SUCCESS))
|
||||
self.authenticated = True
|
||||
else:
|
||||
self._log(DEBUG, 'Auth rejected.')
|
||||
self._log(INFO, 'Auth rejected (%s).' % method)
|
||||
m.add_byte(chr(MSG_USERAUTH_FAILURE))
|
||||
m.add_string(self.server_object.get_allowed_auths(username))
|
||||
if result == AUTH_PARTIALLY_SUCCESSFUL:
|
||||
|
|
|
@ -822,7 +822,7 @@ class Channel (object):
|
|||
nbytes = m.get_int()
|
||||
try:
|
||||
self.lock.acquire()
|
||||
if self.ultra_debug or True:
|
||||
if self.ultra_debug:
|
||||
self._log(DEBUG, 'window up %d' % nbytes)
|
||||
self.out_window_size += nbytes
|
||||
self.out_buffer_cv.notifyAll()
|
||||
|
|
|
@ -118,7 +118,7 @@ class BaseSFTP (object):
|
|||
return version
|
||||
|
||||
def _log(self, level, msg):
|
||||
if type(msg) == type([]):
|
||||
if issubclass(type(msg), list):
|
||||
for m in msg:
|
||||
self.logger.log(level, m)
|
||||
else:
|
||||
|
|
|
@ -53,6 +53,7 @@ class SFTPClient (BaseSFTP):
|
|||
transport = self.sock.get_transport()
|
||||
self.logger = logging.getLogger(transport.get_log_channel() + '.' +
|
||||
self.sock.get_name() + '.sftp')
|
||||
self.ultra_debug = transport.ultra_debug
|
||||
self._send_version()
|
||||
|
||||
def from_transport(selfclass, t):
|
||||
|
|
|
@ -57,10 +57,10 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
|
|||
"""
|
||||
BaseSFTP.__init__(self)
|
||||
SubsystemHandler.__init__(self, channel, name)
|
||||
self.ultra_debug = True
|
||||
transport = channel.get_transport()
|
||||
self.logger = logging.getLogger(transport.get_log_channel() + '.' +
|
||||
channel.get_name() + '.sftp')
|
||||
self.ultra_debug = transport.ultra_debug
|
||||
self.next_handle = 1
|
||||
# map of handle-string to SFTPHandle for files & folders:
|
||||
self.file_table = { }
|
||||
|
|
|
@ -806,12 +806,24 @@ class BaseTransport (threading.Thread):
|
|||
"""
|
||||
return self.log_name
|
||||
|
||||
def set_hexdump(self, hexdump):
|
||||
"""
|
||||
Turn on/off logging a hex dump of protocol traffic at DEBUG level in
|
||||
the logs. Normally you would want this off (which is the default),
|
||||
but if you are debugging something, it may be useful.
|
||||
|
||||
@param hexdump: C{True} to log protocol traffix (in hex) to the log;
|
||||
C{False} otherwise.
|
||||
@type hexdump: bool
|
||||
"""
|
||||
self.ultra_debug = hexdump
|
||||
|
||||
|
||||
### internals...
|
||||
|
||||
|
||||
def _log(self, level, msg):
|
||||
if type(msg) == type([]):
|
||||
if issubclass(type(msg), list):
|
||||
for m in msg:
|
||||
self.logger.log(level, m)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue