You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tw...@apache.org on 2021/10/28 22:21:20 UTC

[mina-sshd] branch master updated: [SSHD-1218] Fix bug

This is an automated email from the ASF dual-hosted git repository.

twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git


The following commit(s) were added to refs/heads/master by this push:
     new ce6d0e6  [SSHD-1218] Fix bug
ce6d0e6 is described below

commit ce6d0e6b0a1e62efdfb0f33d8b715c78a50aa4e4
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Fri Oct 29 00:20:08 2021 +0200

    [SSHD-1218] Fix bug
    
    Attributes cannot be set to null. Set UserAuthPublicKey.IDENTITY_AGENT
    to the empty string if not defined in the HostConfigEntry.
---
 sshd-core/src/main/java/org/apache/sshd/client/SshClient.java          | 3 ++-
 .../java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 047c9e2..eead8d1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -739,7 +739,8 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
         session.setConnectAddress(address);
         boolean useDefaultIdentities = !hostConfig.isIdentitiesOnly();
         session.setAttribute(UserAuthPublicKey.USE_DEFAULT_IDENTITIES, Boolean.valueOf(useDefaultIdentities));
-        session.setAttribute(UserAuthPublicKey.IDENTITY_AGENT, hostConfig.getProperty(HostConfigEntry.IDENTITY_AGENT));
+        String identityAgent = hostConfig.getProperty(HostConfigEntry.IDENTITY_AGENT);
+        session.setAttribute(UserAuthPublicKey.IDENTITY_AGENT, identityAgent == null ? "" : identityAgent);
 
         if (useDefaultIdentities) {
             setupDefaultSessionIdentities(session, identities);
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
index 6d6971d..427dbf2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java
@@ -66,7 +66,7 @@ public class UserAuthPublicKey extends AbstractUserAuth implements SignatureFact
 
     /**
      * Is set on a {@link ClientSession} when it is created; contains the value of the {@code IdentityAgent} SSH config
-     * setting. May be {@code null} if not specified in the
+     * setting. May be the empty string if not specified in the
      * {@link org.apache.sshd.client.config.hosts.HostConfigEntry#IDENTITY_AGENT HostConfigEntry}.
      */
     public static final AttributeKey<String> IDENTITY_AGENT = new AttributeKey<>();