summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2005-01-25 05:17:55 +0000
committerRobey Pointer <robey@lag.net>2005-01-25 05:17:55 +0000
commitc1ed20c4afaa4715f0ec1f4f802a587b3935f48f (patch)
treea1ad292adf2aed88084520910bfa32280e119adb
parent8878a5f3c28e02796af01bab91532dd05a3624f2 (diff)
[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".
-rw-r--r--paramiko/auth_transport.py12
-rw-r--r--paramiko/channel.py2
-rw-r--r--paramiko/sftp.py2
-rw-r--r--paramiko/sftp_client.py1
-rw-r--r--paramiko/sftp_server.py2
-rw-r--r--paramiko/transport.py14
6 files changed, 23 insertions, 10 deletions
diff --git a/paramiko/auth_transport.py b/paramiko/auth_transport.py
index 00aba9cc..b6da9bb8 100644
--- a/paramiko/auth_transport.py
+++ b/paramiko/auth_transport.py
@@ -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:
diff --git a/paramiko/channel.py b/paramiko/channel.py
index b41136c4..978022d8 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -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()
diff --git a/paramiko/sftp.py b/paramiko/sftp.py
index d37c5447..c11564ad 100644
--- a/paramiko/sftp.py
+++ b/paramiko/sftp.py
@@ -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:
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index 628a9b21..f40a536c 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -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):
diff --git a/paramiko/sftp_server.py b/paramiko/sftp_server.py
index e03131b3..318da02e 100644
--- a/paramiko/sftp_server.py
+++ b/paramiko/sftp_server.py
@@ -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 = { }
diff --git a/paramiko/transport.py b/paramiko/transport.py
index 5925b120..25a82dd8 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -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: