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 2018/11/18 05:03:09 UTC

mina-sshd git commit: [SSHD-866] Counting empty challenges separately when enforcing max. attempts during 'keyboard-interactive' authentication

Repository: mina-sshd
Updated Branches:
  refs/heads/master 025df0e85 -> a6dffd5ac


[SSHD-866] Counting empty challenges separately when enforcing max. attempts during 'keyboard-interactive' authentication


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

Branch: refs/heads/master
Commit: a6dffd5ace48fc6042ae81c3ad5fde4d628f61c9
Parents: 025df0e
Author: Lyor Goldstein <lg...@apache.org>
Authored: Sun Nov 18 07:02:44 2018 +0200
Committer: Lyor Goldstein <lg...@apache.org>
Committed: Sun Nov 18 07:02:56 2018 +0200

----------------------------------------------------------------------
 CHANGES.md                                                |  3 +++
 .../client/auth/keyboard/UserAuthKeyboardInteractive.java | 10 +++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6dffd5a/CHANGES.md
----------------------------------------------------------------------
diff --git a/CHANGES.md b/CHANGES.md
index 1b1d0df..e79d215 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -85,3 +85,6 @@ key loading methods are invoked.
 
 * [SSHD-864](https://issues.apache.org/jira/browse/SSHD-864) - Using a `NamedResource` instead of plain old string
 in order to provide key file(s) location information
+
+* [SSHD-866](https://issues.apache.org/jira/browse/SSHD-866) - Counting empty challenges separately when enforcing
+max. attempts during `keyboard-interactive` authentication

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/a6dffd5a/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
index c97c72d..c27a4c4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java
@@ -76,6 +76,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
 
     private final AtomicBoolean requestPending = new AtomicBoolean(false);
     private final AtomicInteger trialsCount = new AtomicInteger(0);
+    private final AtomicInteger emptyCount = new AtomicInteger(0);
     private Iterator<String> passwords;
     private int maxTrials;
 
@@ -150,11 +151,10 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
                   session, service, name, instruction, lang, num);
         }
 
-        if (num > 0) {
-            // SSHD-866
-            if (!verifyTrialsCount(session, service, cmd, trialsCount.incrementAndGet(), maxTrials)) {
-                return false;
-            }
+        // SSHD-866
+        int retriesCount = (num > 0) ? trialsCount.incrementAndGet() : emptyCount.incrementAndGet();
+        if (!verifyTrialsCount(session, service, cmd, retriesCount, maxTrials)) {
+            return false;
         }
 
         String[] prompt = (num > 0) ? new String[num] : GenericUtils.EMPTY_STRING_ARRAY;