You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2020/05/26 12:13:05 UTC
[mina-sshd] branch master updated (35421eb -> adff42b)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git.
from 35421eb Avoid unnecessary cast to AbstractSession
new bccf6d4 Remove unused import
new 75071c6 ChannelSession: Split parsing from handlers
new adff42b ChannelSession: Consistently use RequestHandler.Result
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/sshd/server/channel/ChannelSession.java | 61 ++++++++++++++++++++--
.../java/org/apache/sshd/client/ClientTest.java | 1 -
2 files changed, 56 insertions(+), 6 deletions(-)
[mina-sshd] 02/03: ChannelSession: Split parsing from handlers
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 75071c60d683124c93b6bdeb5d90ffe2acec0e8b
Author: w <none>
AuthorDate: Mon Oct 7 22:31:22 2019 -0700
ChannelSession: Split parsing from handlers
# Conflicts:
# sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
---
.../apache/sshd/server/channel/ChannelSession.java | 58 ++++++++++++++++++++--
1 file changed, 55 insertions(+), 3 deletions(-)
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index ce642dd..bcc3e6d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -427,10 +428,14 @@ public class ChannelSession extends AbstractServerChannel {
protected RequestHandler.Result handleEnv(Buffer buffer, boolean wantReply) throws IOException {
String name = buffer.getString();
String value = buffer.getString();
- addEnvVariable(name, value);
if (log.isDebugEnabled()) {
log.debug("handleEnv({}): {} = {}", this, name, value);
}
+ return handleEnvParsed(name, value);
+ }
+
+ protected RequestHandler.Result handleEnvParsed(String name, String value) throws IOException {
+ addEnvVariable(name, value);
return RequestHandler.Result.ReplySuccess;
}
@@ -441,9 +446,8 @@ public class ChannelSession extends AbstractServerChannel {
int tWidth = buffer.getInt();
int tHeight = buffer.getInt();
byte[] modes = buffer.getBytes();
- Environment environment = getEnvironment();
- Map<PtyMode, Integer> ptyModes = environment.getPtyModes();
+ Map<PtyMode, Integer> ptyModes = new HashMap<>();
for (int i = 0; (i < modes.length) && (modes[i] != PtyMode.TTY_OP_END);) {
int opcode = modes[i++] & 0x00FF;
/*
@@ -473,6 +477,15 @@ public class ChannelSession extends AbstractServerChannel {
this, term, tColumns, tRows, tWidth, tHeight, ptyModes);
}
+ return handlePtyReqParsed(term, tColumns, tRows, tWidth, tHeight, ptyModes);
+ }
+
+ protected RequestHandler.Result handlePtyReqParsed(
+ String term, int tColumns, int tRows, int tWidth, int tHeight,
+ Map<PtyMode, Integer> ptyModes)
+ throws IOException {
+ Environment environment = getEnvironment();
+ environment.getPtyModes().putAll(ptyModes);
addEnvVariable(Environment.ENV_TERM, term);
addEnvVariable(Environment.ENV_COLUMNS, Integer.toString(tColumns));
addEnvVariable(Environment.ENV_LINES, Integer.toString(tRows));
@@ -489,6 +502,12 @@ public class ChannelSession extends AbstractServerChannel {
this, tColumns, tRows, tWidth, tHeight);
}
+ return handleWindowChangeParsed(tColumns, tRows, tWidth, tHeight);
+ }
+
+ protected RequestHandler.Result handleWindowChangeParsed(
+ int tColumns, int tRows, int tWidth, int tHeight)
+ throws IOException {
StandardEnvironment e = getEnvironment();
e.set(Environment.ENV_COLUMNS, Integer.toString(tColumns));
e.set(Environment.ENV_LINES, Integer.toString(tRows));
@@ -503,6 +522,10 @@ public class ChannelSession extends AbstractServerChannel {
log.debug("handleSignal({}): {}", this, name);
}
+ return handleSignalParsed(name);
+ }
+
+ protected RequestHandler.Result handleSignalParsed(String name) throws IOException {
Signal signal = Signal.get(name);
if (signal != null) {
StandardEnvironment environ = getEnvironment();
@@ -520,6 +543,10 @@ public class ChannelSession extends AbstractServerChannel {
log.debug("handleBreak({}) length={}", this, breakLength);
}
+ return handleBreakParsed(breakLength);
+ }
+
+ protected RequestHandler.Result handleBreakParsed(long breakLength) throws IOException {
StandardEnvironment environ = getEnvironment();
environ.signal(this, Signal.INT);
return RequestHandler.Result.ReplySuccess;
@@ -536,6 +563,10 @@ public class ChannelSession extends AbstractServerChannel {
return RequestHandler.Result.ReplyFailure;
}
+ return handleShellParsed(request);
+ }
+
+ protected RequestHandler.Result handleShellParsed(String request) throws IOException {
ServerSession shellSession = Objects.requireNonNull(getServerSession(), "No server session");
ServerFactoryManager manager = Objects.requireNonNull(shellSession.getFactoryManager(), "No server factory manager");
ShellFactory factory = manager.getShellFactory();
@@ -576,6 +607,12 @@ public class ChannelSession extends AbstractServerChannel {
}
String commandLine = buffer.getString();
+ return handleExecParsed(request, commandLine);
+ }
+
+ protected RequestHandler.Result handleExecParsed(
+ String request, String commandLine)
+ throws IOException {
ServerSession cmdSession = Objects.requireNonNull(getServerSession(), "No server session");
ServerFactoryManager manager = Objects.requireNonNull(cmdSession.getFactoryManager(), "No server factory manager");
CommandFactory factory = manager.getCommandFactory();
@@ -617,6 +654,10 @@ public class ChannelSession extends AbstractServerChannel {
log.debug("handleSubsystem({})[want-reply={}] subsystem={}", this, wantReply, subsystem);
}
+ return handleSubsystemParsed(request, subsystem);
+ }
+
+ protected RequestHandler.Result handleSubsystemParsed(String request, String subsystem) throws IOException {
ServerFactoryManager manager = Objects.requireNonNull(getServerSession(), "No server session").getFactoryManager();
Collection<SubsystemFactory> factories
= Objects.requireNonNull(manager, "No server factory manager").getSubsystemFactories();
@@ -798,6 +839,10 @@ public class ChannelSession extends AbstractServerChannel {
protected RequestHandler.Result handleAgentForwarding(
String requestType, Buffer buffer, boolean wantReply)
throws IOException {
+ return handleAgentForwardingParsed(requestType);
+ }
+
+ protected RequestHandler.Result handleAgentForwardingParsed(String requestType) throws IOException {
ServerSession session = getServerSession();
PropertyResolverUtils.updateProperty(
session, FactoryManager.AGENT_FORWARDING_TYPE, requestType);
@@ -845,6 +890,13 @@ public class ChannelSession extends AbstractServerChannel {
String authCookie = buffer.getString();
int screenId = buffer.getInt();
+ return handleX11ForwardingParsed(requestType, session, singleConnection, authProtocol, authCookie, screenId);
+ }
+
+ protected RequestHandler.Result handleX11ForwardingParsed(
+ String requestType, ServerSession session, boolean singleConnection,
+ String authProtocol, String authCookie, int screenId)
+ throws IOException {
FactoryManager manager = Objects.requireNonNull(session.getFactoryManager(), "No factory manager");
X11ForwardingFilter filter = manager.getX11ForwardingFilter();
boolean debugEnabled = log.isDebugEnabled();
[mina-sshd] 03/03: ChannelSession: Consistently use
RequestHandler.Result
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit adff42b650ac9bc0d2da4c3a4dec5c8099197042
Author: w <none>
AuthorDate: Mon Oct 7 22:23:49 2019 -0700
ChannelSession: Consistently use RequestHandler.Result
# Conflicts:
# sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
---
.../src/main/java/org/apache/sshd/server/channel/ChannelSession.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index bcc3e6d..3303584 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -45,7 +45,6 @@ import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.channel.ChannelRequestHandler;
import org.apache.sshd.common.channel.PtyMode;
import org.apache.sshd.common.channel.RequestHandler;
-import org.apache.sshd.common.channel.RequestHandler.Result;
import org.apache.sshd.common.channel.Window;
import org.apache.sshd.common.file.FileSystemAware;
import org.apache.sshd.common.file.FileSystemFactory;
@@ -386,7 +385,7 @@ public class ChannelSession extends AbstractServerChannel {
@Override
protected IoWriteFuture sendResponse(
- Buffer buffer, String req, Result result, boolean wantReply)
+ Buffer buffer, String req, RequestHandler.Result result, boolean wantReply)
throws IOException {
IoWriteFuture future = super.sendResponse(buffer, req, result, wantReply);
if (!RequestHandler.Result.ReplySuccess.equals(result)) {
[mina-sshd] 01/03: Remove unused import
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit bccf6d4e9049531d843a6af07356deade6b73d6b
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue May 26 11:53:50 2020 +0200
Remove unused import
---
sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
index 1fcc1ef..860dc44 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
@@ -88,7 +88,6 @@ import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
-import org.apache.sshd.common.session.helpers.AbstractSession;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;