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/09 11:07:06 UTC

[3/6] mina-sshd git commit: Send SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE if failed to create requested service

Send SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE if failed to create requested service

* As sanctioned by RFC4253 section 10


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/05f5d36c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/05f5d36c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/05f5d36c

Branch: refs/heads/master
Commit: 05f5d36c073a3b0ec789ef4a77835b75fc0d6455
Parents: 2a3d0fd
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Wed Dec 9 11:57:04 2015 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Wed Dec 9 11:57:04 2015 +0200

----------------------------------------------------------------------
 .../apache/sshd/server/session/ServerSessionImpl.java | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/05f5d36c/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java
index f506924..32ae420 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerSessionImpl.java
@@ -66,7 +66,19 @@ public class ServerSessionImpl extends AbstractServerSession {
 
     @Override
     public void startService(String name) throws Exception {
-        currentService = ServiceFactory.Utils.create(getFactoryManager().getServiceFactories(), name, this);
+        currentService = ServiceFactory.Utils.create(
+                        getFactoryManager().getServiceFactories(),
+                        ValidateUtils.checkNotNullAndNotEmpty(name, "No service name"),
+                        this);
+        /*
+         * According to RFC4253:
+         *
+         *      If the server rejects the service request, it SHOULD send an
+         *      appropriate SSH_MSG_DISCONNECT message and MUST disconnect.
+         */
+        if (currentService == null) {
+            throw new SshException(SshConstants.SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE, "Unknown service: " + name);
+        }
     }
 
     @Override