You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2015/12/08 08:48:57 UTC
[1/2] mina-sshd git commit: Define SSH_EXTENDED_DATA_STDERR and use
it instead of just the value '1'
Repository: mina-sshd
Updated Branches:
refs/heads/master 53055cb53 -> 567a6af73
Define SSH_EXTENDED_DATA_STDERR and use it instead of just the value '1'
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/c5b3771c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/c5b3771c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/c5b3771c
Branch: refs/heads/master
Commit: c5b3771c517ff82e9fcbd3830dad6ea11af07b0d
Parents: 53055cb
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Dec 8 09:47:53 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Dec 8 09:47:53 2015 +0200
----------------------------------------------------------------------
.../main/java/org/apache/sshd/common/SshConstants.java | 3 +++
.../org/apache/sshd/common/channel/AbstractChannel.java | 12 ++++++++----
.../sshd/common/channel/ChannelAsyncOutputStream.java | 2 +-
.../apache/sshd/common/channel/ChannelOutputStream.java | 6 ++----
4 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c5b3771c/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
index a254d48..3c7b336 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/SshConstants.java
@@ -119,6 +119,9 @@ public final class SshConstants {
public static final int SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
public static final int SSH_OPEN_RESOURCE_SHORTAGE = 4;
+ // Some more constants
+ public static final int SSH_EXTENDED_DATA_STDERR = 1; // see RFC4254 section 5.2
+
private SshConstants() {
throw new UnsupportedOperationException("No instance allowed");
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c5b3771c/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 2165ee5..29ea76f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -450,9 +450,9 @@ public abstract class AbstractChannel
public void handleExtendedData(Buffer buffer) throws IOException {
int ex = buffer.getInt();
// Only accept extended data for stderr
- if (ex != 1) {
+ if (ex != SshConstants.SSH_EXTENDED_DATA_STDERR) {
if (log.isDebugEnabled()) {
- log.debug("handleExtendedData({}) send SSH_MSG_CHANNEL_FAILURE", this);
+ log.debug("handleExtendedData({}) send SSH_MSG_CHANNEL_FAILURE - non STDERR type: {}", this, ex);
}
Session s = getSession();
buffer = s.prepareBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, BufferUtils.clear(buffer));
@@ -464,7 +464,9 @@ public abstract class AbstractChannel
if (len < 0 || len > ByteArrayBuffer.MAX_LEN) {
throw new IllegalStateException("Bad item length: " + len);
}
- log.debug("handleExtendedData({}) SSH_MSG_CHANNEL_EXTENDED_DATA len={}", this, len);
+ if (log.isDebugEnabled()) {
+ log.debug("handleExtendedData({}) SSH_MSG_CHANNEL_EXTENDED_DATA len={}", this, len);
+ }
if (log.isTraceEnabled()) {
log.trace("handleExtendedData({}) extended data: {}", this, BufferUtils.printHex(buffer.array(), buffer.rpos(), len));
}
@@ -510,7 +512,9 @@ public abstract class AbstractChannel
protected abstract void doWriteExtendedData(byte[] data, int off, int len) throws IOException;
protected void sendEof() throws IOException {
- log.debug("sendEof({}) SSH_MSG_CHANNEL_EOF", this);
+ if (log.isDebugEnabled()) {
+ log.debug("sendEof({}) SSH_MSG_CHANNEL_EOF", this);
+ }
Session s = getSession();
Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_CHANNEL_EOF, Short.SIZE);
buffer.putInt(getRecipient());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c5b3771c/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
index c5c9c17..c790f29 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelAsyncOutputStream.java
@@ -94,7 +94,7 @@ public class ChannelAsyncOutputStream extends AbstractCloseable implements IoOut
Buffer buf = s.createBuffer(cmd, length + 12);
buf.putInt(channel.getRecipient());
if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) {
- buf.putInt(1);
+ buf.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
}
buf.putInt(length);
buf.putRawBytes(buffer.array(), buffer.rpos(), length);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/c5b3771c/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
index 4f17882..27fe429 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/ChannelOutputStream.java
@@ -171,9 +171,7 @@ public class ChannelOutputStream extends OutputStream implements Channel {
session.resetIdleTimeout();
remoteWindow.waitAndConsume(length, maxWaitTimeout);
if (log.isTraceEnabled()) {
- log.trace("Send {} on channel {}",
- (cmd == SshConstants.SSH_MSG_CHANNEL_DATA) ? "SSH_MSG_CHANNEL_DATA" : "SSH_MSG_CHANNEL_EXTENDED_DATA",
- channel);
+ log.trace("flush({}) send {}", channel, SshConstants.getCommandMessageName(cmd));
}
channel.writePacket(buf);
}
@@ -218,7 +216,7 @@ public class ChannelOutputStream extends OutputStream implements Channel {
buffer = session.createBuffer(cmd, size <= 0 ? 12 : 12 + size);
buffer.putInt(channel.getRecipient());
if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) {
- buffer.putInt(1);
+ buffer.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
}
buffer.putInt(0);
bufferLength = 0;
[2/2] mina-sshd git commit: Send SSH2_DISCONNECT_TOO_MANY_CONNECTIONS
as disconnect reason if max. configured concurrent session limit exceeded
Posted by lg...@apache.org.
Send SSH2_DISCONNECT_TOO_MANY_CONNECTIONS as disconnect reason if max. configured concurrent session limit exceeded
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/567a6af7
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/567a6af7
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/567a6af7
Branch: refs/heads/master
Commit: 567a6af73d9bafc324f99c58c3b23ae1aa1ce1c7
Parents: c5b3771
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Dec 8 09:48:42 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Dec 8 09:48:42 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/sshd/server/session/ServerUserAuthService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/567a6af7/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index dcded35..977bdc4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -220,7 +220,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
if (maxSessionCount != null) {
int currentSessionCount = session.getActiveSessionCountForUser(username);
if (currentSessionCount >= maxSessionCount) {
- session.disconnect(SshConstants.SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE,
+ session.disconnect(SshConstants.SSH2_DISCONNECT_TOO_MANY_CONNECTIONS,
"Too many concurrent connections (" + currentSessionCount + ") - max. allowed: " + maxSessionCount);
return;
}