Author: gnodet
Date: Mon May 21 15:28:48 2012
New Revision: 1341069
URL: http://svn.apache.org/viewvc?rev=1341069&view=rev
Log:
[SSHD-126] Reduce overall logging
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
Mon May 21 15:28:48 2012
@@ -26,8 +26,6 @@ import org.apache.sshd.common.Session;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.DefaultCloseFuture;
-import org.apache.sshd.common.future.SshFuture;
-import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.util.Buffer;
import org.apache.sshd.common.util.BufferUtils;
import org.slf4j.Logger;
@@ -84,14 +82,14 @@ public abstract class AbstractChannel im
try {
synchronized (lock) {
if (immediately) {
- log.info("Closing channel {} immediately", id);
+ log.debug("Closing channel {} immediately", id);
closeFuture.setClosed();
lock.notifyAll();
session.unregisterChannel(this);
} else {
if (!closing) {
closing = true;
- log.info("Send SSH_MSG_CHANNEL_CLOSE on channel {}",
id);
+ log.debug("Send SSH_MSG_CHANNEL_CLOSE on channel {}",
id);
Buffer buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_CLOSE, 0);
buffer.putInt(recipient);
session.writePacket(buffer);
@@ -106,7 +104,7 @@ public abstract class AbstractChannel im
}
public void handleClose() throws IOException {
- log.info("Received SSH_MSG_CHANNEL_CLOSE on channel {}", id);
+ log.debug("Received SSH_MSG_CHANNEL_CLOSE on channel {}", id);
synchronized (lock) {
close(false).setClosed();
doClose();
@@ -133,7 +131,7 @@ public abstract class AbstractChannel im
int ex = buffer.getInt();
// Only accept extended data for stderr
if (ex != 1) {
- log.info("Send SSH_MSG_CHANNEL_FAILURE on channel {}", id);
+ log.debug("Send SSH_MSG_CHANNEL_FAILURE on channel {}", id);
buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
buffer.putInt(recipient);
session.writePacket(buffer);
@@ -151,7 +149,7 @@ public abstract class AbstractChannel im
}
public void handleEof() throws IOException {
- log.info("Received SSH_MSG_CHANNEL_EOF on channel {}", id);
+ log.debug("Received SSH_MSG_CHANNEL_EOF on channel {}", id);
synchronized (lock) {
eof = true;
lock.notifyAll();
@@ -159,13 +157,13 @@ public abstract class AbstractChannel im
}
public void handleWindowAdjust(Buffer buffer) throws IOException {
- log.info("Received SSH_MSG_CHANNEL_WINDOW_ADJUST on channel {}", id);
+ log.debug("Received SSH_MSG_CHANNEL_WINDOW_ADJUST on channel {}", id);
int window = buffer.getInt();
remoteWindow.expand(window);
}
public void handleFailure() throws IOException {
- log.info("Received SSH_MSG_CHANNEL_FAILURE on channel {}", id);
+ log.debug("Received SSH_MSG_CHANNEL_FAILURE on channel {}", id);
// TODO: do something to report failed requests?
}
@@ -174,7 +172,7 @@ public abstract class AbstractChannel im
protected abstract void doWriteExtendedData(byte[] data, int off, int len)
throws IOException;
protected void sendEof() throws IOException {
- log.info("Send SSH_MSG_CHANNEL_EOF on channel {}", id);
+ log.debug("Send SSH_MSG_CHANNEL_EOF on channel {}", id);
Buffer buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_EOF, 0);
buffer.putInt(recipient);
session.writePacket(buffer);
@@ -187,7 +185,7 @@ public abstract class AbstractChannel im
}
protected void sendWindowAdjust(int len) throws IOException {
- log.info("Send SSH_MSG_CHANNEL_WINDOW_ADJUST on channel {}", id);
+ log.debug("Send SSH_MSG_CHANNEL_WINDOW_ADJUST on channel {}", id);
Buffer buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_WINDOW_ADJUST, 0);
buffer.putInt(recipient);
buffer.putInt(len);
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractSession.java
Mon May 21 15:28:48 2012
@@ -278,7 +278,7 @@ public abstract class AbstractSession im
* The call will not block until the mina session is actually closed.
*/
public CloseFuture close(final boolean immediately) {
- final Session s = this;
+ final AbstractSession s = this;
class IoSessionCloser implements IoFutureListener {
public void operationComplete(IoFuture future) {
synchronized (lock) {
@@ -287,6 +287,7 @@ public abstract class AbstractSession im
lock.notifyAll();
}
+ log.info("Session {}@{} closed", s.getUsername(),
s.getIoSession().getRemoteAddress());
// Fire 'close' event
final ArrayList<SessionListener> l =
new ArrayList<SessionListener>(listeners);
@@ -300,7 +301,7 @@ public abstract class AbstractSession im
if (!closing) {
try {
closing = true;
- log.info("Closing session");
+ log.debug("Closing session");
Channel[] channelToClose = channels.values().toArray(new
Channel[channels.values().size()]);
if (channelToClose.length > 0) {
final AtomicInteger latch = new
AtomicInteger(channelToClose.length);
@@ -704,7 +705,7 @@ public abstract class AbstractSession im
* @throws IOException if an error occurs sending the message
*/
protected void sendNewKeys() throws IOException {
- log.info("Send SSH_MSG_NEWKEYS");
+ log.debug("Send SSH_MSG_NEWKEYS");
Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_NEWKEYS, 0);
writePacket(buffer);
}
@@ -921,7 +922,7 @@ public abstract class AbstractSession im
protected void channelOpenConfirmation(Buffer buffer) throws IOException {
Channel channel = getChannel(buffer);
- log.info("Received SSH_MSG_CHANNEL_OPEN_CONFIRMATION on channel {}",
channel.getId());
+ log.debug("Received SSH_MSG_CHANNEL_OPEN_CONFIRMATION on channel {}",
channel.getId());
int recipient = buffer.getInt();
int rwsize = buffer.getInt();
int rmpsize = buffer.getInt();
@@ -930,7 +931,7 @@ public abstract class AbstractSession im
protected void channelOpenFailure(Buffer buffer) throws IOException {
AbstractClientChannel channel = (AbstractClientChannel)
getChannel(buffer);
- log.info("Received SSH_MSG_CHANNEL_OPEN_FAILURE on channel {}",
channel.getId());
+ log.debug("Received SSH_MSG_CHANNEL_OPEN_FAILURE on channel {}",
channel.getId());
channels.remove(channel.getId());
channel.handleOpenFailure(buffer);
}
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
Mon May 21 15:28:48 2012
@@ -59,7 +59,7 @@ public abstract class AbstractServerChan
protected void sendExitStatus(int v) throws IOException {
if (!exitStatusSent) {
exitStatusSent = true;
- log.info("Send SSH_MSG_CHANNEL_REQUEST exit-status on channel {}",
id);
+ log.debug("Send SSH_MSG_CHANNEL_REQUEST exit-status on channel
{}", id);
Buffer buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_REQUEST, 0);
buffer.putInt(recipient);
buffer.putString("exit-status");
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
Mon May 21 15:28:48 2012
@@ -189,9 +189,9 @@ public class ChannelSession extends Abst
}
public void handleRequest(Buffer buffer) throws IOException {
- log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id);
+ log.debug("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id);
String type = buffer.getString();
- log.info("Received channel request: {}", type);
+ log.debug("Received channel request: {}", type);
if (!handleRequest(type, buffer)) {
buffer =
session.createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_FAILURE, 0);
buffer.putInt(recipient);
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/kex/AbstractDHGServer.java
Mon May 21 15:28:48 2012
@@ -81,7 +81,7 @@ public abstract class AbstractDHGServer
throw new
SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
"Protocol error: expected packet " +
SshConstants.Message.SSH_MSG_KEXDH_INIT + ", got " + cmd);
}
- log.info("Received SSH_MSG_KEXDH_INIT");
+ log.debug("Received SSH_MSG_KEXDH_INIT");
e = buffer.getMPIntAsBytes();
dh.setF(e);
K = dh.getK();
@@ -122,7 +122,7 @@ public abstract class AbstractDHGServer
}
// Send response
- log.info("Send SSH_MSG_KEXDH_REPLY");
+ log.debug("Send SSH_MSG_KEXDH_REPLY");
buffer.clear();
buffer.rpos(5);
buffer.wpos(5);
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
URL:
http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java?rev=1341069&r1=1341068&r2=1341069&view=diff
==============================================================================
---
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
(original)
+++
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSession.java
Mon May 21 15:28:48 2012
@@ -87,7 +87,7 @@ public class ServerSession extends Abstr
tcpipForward = new TcpipForwardSupport(this);
agentForward = new AgentForwardSupport(this);
x11Forward = new X11ForwardSupport(this);
- log.info("Session created...");
+ log.info("Session created from {}", ioSession.getRemoteAddress());
sendServerIdentification();
sendKexInit();
}
@@ -129,32 +129,32 @@ public class ServerSession extends Abstr
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();
String msg = buffer.getString();
- log.info("Received SSH_MSG_DISCONNECT (reason={}, msg={})",
code, msg);
+ log.debug("Received SSH_MSG_DISCONNECT (reason={}, msg={})",
code, msg);
close(true);
break;
}
case SSH_MSG_UNIMPLEMENTED: {
int code = buffer.getInt();
- log.info("Received SSH_MSG_UNIMPLEMENTED #{}", code);
+ log.debug("Received SSH_MSG_UNIMPLEMENTED #{}", code);
break;
}
case SSH_MSG_DEBUG: {
boolean display = buffer.getBoolean();
String msg = buffer.getString();
- log.info("Received SSH_MSG_DEBUG (display={}) '{}'", display,
msg);
+ log.debug("Received SSH_MSG_DEBUG (display={}) '{}'", display,
msg);
break;
}
case SSH_MSG_IGNORE:
- log.info("Received SSH_MSG_IGNORE");
+ log.debug("Received SSH_MSG_IGNORE");
break;
default:
switch (state) {
case ReceiveKexInit:
if (cmd != SshConstants.Message.SSH_MSG_KEXINIT) {
- log.error("Ignoring command " + cmd + " while
waiting for " + SshConstants.Message.SSH_MSG_KEXINIT);
+ log.warn("Ignoring command " + cmd + " while
waiting for " + SshConstants.Message.SSH_MSG_KEXINIT);
break;
}
- log.info("Received SSH_MSG_KEXINIT");
+ log.debug("Received SSH_MSG_KEXINIT");
receiveKexInit(buffer);
negociate();
kex =
NamedFactory.Utils.create(factoryManager.getKeyExchangeFactories(),
negociated[SshConstants.PROPOSAL_KEX_ALGS]);
@@ -173,18 +173,18 @@ public class ServerSession extends Abstr
disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Protocol error:
expected packet " + SshConstants.Message.SSH_MSG_NEWKEYS + ", got " + cmd);
return;
}
- log.info("Received SSH_MSG_NEWKEYS");
+ log.debug("Received SSH_MSG_NEWKEYS");
receiveNewKeys(true);
state = State.WaitingUserAuth;
scheduleAuthTimer();
break;
case WaitingUserAuth:
if (cmd !=
SshConstants.Message.SSH_MSG_SERVICE_REQUEST) {
- log.info("Expecting a {}, but received {}",
SshConstants.Message.SSH_MSG_SERVICE_REQUEST, cmd);
+ log.debug("Expecting a {}, but received {}",
SshConstants.Message.SSH_MSG_SERVICE_REQUEST, cmd);
notImplemented();
} else {
String request = buffer.getString();
- log.info("Received SSH_MSG_SERVICE_REQUEST '{}'",
request);
+ log.debug("Received SSH_MSG_SERVICE_REQUEST '{}'",
request);
if ("ssh-userauth".equals(request)) {
userAuth(buffer, null);
} else {
@@ -197,7 +197,7 @@ public class ServerSession extends Abstr
disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Protocol error:
expected packet " + SshConstants.Message.SSH_MSG_USERAUTH_REQUEST + ", got " +
cmd);
return;
}
- log.info("Received " + cmd);
+ log.debug("Received " + cmd);
userAuth(buffer, cmd);
break;
case Running:
@@ -341,7 +341,7 @@ public class ServerSession extends Abstr
if (clientVersion == null) {
return false;
}
- log.info("Client version string: {}", clientVersion);
+ log.debug("Client version string: {}", clientVersion);
if (!clientVersion.startsWith("SSH-2.0-")) {
throw new
SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED,
"Unsupported protocol version: " +
clientVersion);
@@ -356,19 +356,19 @@ public class ServerSession extends Abstr
private void serviceRequest(Buffer buffer) throws Exception {
String request = buffer.getString();
- log.info("Received SSH_MSG_SERVICE_REQUEST '{}'", request);
+ log.debug("Received SSH_MSG_SERVICE_REQUEST '{}'", request);
// TODO: handle service requests
disconnect(SshConstants.SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE,
"Unsupported service request: " + request);
}
private void userAuth(Buffer buffer, SshConstants.Message cmd) throws
Exception {
if (state == State.WaitingUserAuth) {
- log.info("Accepting user authentication request");
+ log.debug("Accepting user authentication request");
buffer = createBuffer(SshConstants.Message.SSH_MSG_SERVICE_ACCEPT,
0);
buffer.putString("ssh-userauth");
writePacket(buffer);
userAuthFactories = new
ArrayList<NamedFactory<UserAuth>>(getServerFactoryManager().getUserAuthFactories());
- log.info("Authorized authentication methods: {}",
NamedFactory.Utils.getNames(userAuthFactories));
+ log.debug("Authorized authentication methods: {}",
NamedFactory.Utils.getNames(userAuthFactories));
state = State.UserAuth;
} else {
if (nbAuthRequests++ > maxAuthRequests) {
@@ -384,7 +384,7 @@ public class ServerSession extends Abstr
String svcName = buffer.getString();
String method = buffer.getString();
- log.info("Authenticating user '{}' with method '{}'", username,
method);
+ log.debug("Authenticating user '{}' with method '{}'", username,
method);
NamedFactory<UserAuth> factory =
NamedFactory.Utils.get(userAuthFactories, method);
if (factory != null) {
UserAuth auth = factory.create();
@@ -392,7 +392,7 @@ public class ServerSession extends Abstr
authed = auth.auth(this, username, buffer);
if (authed == null) {
// authentication is still ongoing
- log.info("Authentication not finished");
+ log.debug("Authentication not finished");
if (auth instanceof HandshakingUserAuth) {
currentAuth = (HandshakingUserAuth) auth;
@@ -403,16 +403,16 @@ public class ServerSession extends Abstr
}
return;
} else {
- log.info(authed ? "Authentication succeeded" :
"Authentication failed");
+ log.debug(authed ? "Authentication succeeded" :
"Authentication failed");
}
} catch (Exception e) {
// Continue
authed = false;
- log.info("Authentication failed: {}", e.getMessage());
+ log.debug("Authentication failed: {}", e.getMessage());
}
} else {
- log.info("Unsupported authentication method '{}'", method);
+ log.debug("Unsupported authentication method '{}'", method);
}
} else {
try {
@@ -420,7 +420,7 @@ public class ServerSession extends Abstr
if (authed == null) {
// authentication is still ongoing
- log.info("Authentication still not finished");
+ log.debug("Authentication still not finished");
return;
} else if (authed.booleanValue()) {
username = currentAuth.getUserName();
@@ -428,7 +428,7 @@ public class ServerSession extends Abstr
} catch (Exception e) {
// failed
authed = false;
- log.info("Authentication next failed: {}", e.getMessage());
+ log.debug("Authentication next failed: {}", e.getMessage());
}
}
@@ -459,6 +459,7 @@ public class ServerSession extends Abstr
this.authed = true;
this.username = username;
unscheduleAuthTimer();
+ log.info("Session {}@{} authenticated", getUsername(),
getIoSession().getRemoteAddress());
} else {
buffer =
createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_FAILURE, 0);
NamedFactory.Utils.remove(userAuthFactories, "none"); //
'none' MUST NOT be listed
@@ -497,7 +498,7 @@ public class ServerSession extends Abstr
final int rwsize = buffer.getInt();
final int rmpsize = buffer.getInt();
- log.info("Received SSH_MSG_CHANNEL_OPEN {}", type);
+ log.debug("Received SSH_MSG_CHANNEL_OPEN {}", type);
if (closing) {
Buffer buf =
createBuffer(SshConstants.Message.SSH_MSG_CHANNEL_OPEN_FAILURE, 0);
@@ -576,7 +577,7 @@ public class ServerSession extends Abstr
tcpipForward.cancel(buffer, wantReply);
return;
} else {
- log.info("Received SSH_MSG_GLOBAL_REQUEST {}", req);
+ log.debug("Received SSH_MSG_GLOBAL_REQUEST {}", req);
log.warn("Unknown global request: {}", req);
}
if (wantReply) {