You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2020/08/07 08:25:31 UTC
[GitHub] [mina-sshd] gnodet edited a comment on pull request #156: [SSHD-1050] Fixed race condition in AuthFuture if exception caught before authentication started
gnodet edited a comment on pull request #156:
URL: https://github.com/apache/mina-sshd/pull/156#issuecomment-670396237
@lgoldstein you're right, there are a few tests that do use multiple calls to `auth()`.
So maybe the following instead:
```
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index 21e0631d..9f9b8015 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -85,9 +85,6 @@ public class ClientSessionImpl extends AbstractClientSession {
nextServiceFactory = null;
}
- authFuture = new DefaultAuthFuture(ioSession.getRemoteAddress(), futureLock);
- authFuture.setAuthed(false);
-
signalSessionCreated(ioSession);
/*
@@ -124,9 +121,18 @@ public class ClientSessionImpl extends AbstractClientSession {
ClientUserAuthService authService = getUserAuthService();
synchronized (sessionLock) {
String serviceName = nextServiceName();
- authFuture = ValidateUtils.checkNotNull(
+ authFuture = new DefaultAuthFuture(getIoSession().getRemoteAddress(), futureLock);
+ AuthFuture future = ValidateUtils.checkNotNull(
authService.auth(serviceName), "No auth future generated by service=%s", serviceName);
- return authFuture;
+ future.addListener(f -> {
+ Throwable e = f.getException();
+ if (e != null) {
+ this.authFuture.setException(e);
+ } else {
+ this.authFuture.setAuthed(f.isSuccess());
+ }
+ });
+ return this.authFuture;
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org