aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-02-14 21:24:54 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2018-02-14 21:25:16 +0100
commit6e0f8bacd4a9ff70868f07e5eaa7463d235619f8 (patch)
treea701480b86dfed397e9dbc95fe861d6cd153d402 /org.eclipse.jgit/src/org
parent9ce7e8e76703d0fe3ae398866f06bcee4f03b254 (diff)
parent185e53bce447f75c09c1102c5e803a88009bcd74 (diff)
downloadjgit-6e0f8bacd4a9ff70868f07e5eaa7463d235619f8.tar.gz
jgit-6e0f8bacd4a9ff70868f07e5eaa7463d235619f8.zip
Merge branch 'stable-4.9' into stable-4.10
* stable-4.9: Fix ssh host name handling for Jsch Jsch overrides the port in the URI with the one in ~/.ssh/config Change-Id: Iff9076f65e767bbe8df016337b631bdaeb40ad98 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
index 6b7a1bcd6d..c38182741d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
@@ -121,7 +121,6 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
config = OpenSshConfig.get(fs);
final OpenSshConfig.Host hc = config.lookup(host);
- host = hc.getHostName();
if (port <= 0)
port = hc.getPort();
if (user == null)
@@ -193,13 +192,18 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
return e.getCause() == null && e.getMessage().equals("Auth cancel"); //$NON-NLS-1$
}
- private Session createSession(CredentialsProvider credentialsProvider,
+ // Package visibility for tests
+ Session createSession(CredentialsProvider credentialsProvider,
FS fs, String user, final String pass, String host, int port,
final OpenSshConfig.Host hc) throws JSchException {
final Session session = createSession(hc, user, host, port, fs);
// Jsch will have overridden the explicit user by the one from the SSH
// config file...
setUserName(session, user);
+ // Jsch will also have overridden the port.
+ if (port > 0 && port != session.getPort()) {
+ session.setPort(port);
+ }
// We retry already in getSession() method. JSch must not retry
// on its own.
session.setConfig("MaxAuthTries", "1"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -480,4 +484,14 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
}
}
}
+
+ /**
+ * Set the {@link OpenSshConfig} to use. Intended for use in tests.
+ *
+ * @param config
+ * to use
+ */
+ void setConfig(OpenSshConfig config) {
+ this.config = config;
+ }
}