diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-10-19 09:07:14 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-10-19 09:07:14 +0200 |
commit | f8b0c00e6a8f5628babff6dd37254a21589b6e44 (patch) | |
tree | ea41db1d77d77fd3d9d1ced1f8b7b2bb9f082755 /org.eclipse.jgit.ssh.jsch | |
parent | 7d4f3c22ab26b98b703873c3554fec514f109752 (diff) | |
download | jgit-f8b0c00e6a8f5628babff6dd37254a21589b6e44.tar.gz jgit-f8b0c00e6a8f5628babff6dd37254a21589b6e44.zip |
Set JSch global config values only if not set already
Bug: 576604
Change-Id: I04415f07bf2023bc8435c097d1d3c65221d563f1
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.ssh.jsch')
-rw-r--r-- | org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java index 453433e0c4..77b68bb034 100644 --- a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java +++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java @@ -45,6 +45,7 @@ import org.eclipse.jgit.transport.SshConstants; import org.eclipse.jgit.transport.SshSessionFactory; import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.util.FS; +import org.eclipse.jgit.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -417,14 +418,26 @@ public class JschConfigSessionFactory extends SshSessionFactory { */ protected JSch createDefaultJSch(FS fs) throws JSchException { final JSch jsch = new JSch(); - JSch.setConfig("ssh-rsa", JSch.getConfig("signature.rsa")); //$NON-NLS-1$ //$NON-NLS-2$ - JSch.setConfig("ssh-dss", JSch.getConfig("signature.dss")); //$NON-NLS-1$ //$NON-NLS-2$ + // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=537790 and + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=576604 + copyGlobalConfigIfNotSet("signature.rsa", "ssh-rsa"); //$NON-NLS-1$ //$NON-NLS-2$ + copyGlobalConfigIfNotSet("signature.dss", "ssh-dss"); //$NON-NLS-1$ //$NON-NLS-2$ configureJSch(jsch); knownHosts(jsch, fs); identities(jsch, fs); return jsch; } + private void copyGlobalConfigIfNotSet(String from, String to) { + String toValue = JSch.getConfig(to); + if (StringUtils.isEmptyOrNull(toValue)) { + String fromValue = JSch.getConfig(from); + if (!StringUtils.isEmptyOrNull(fromValue)) { + JSch.setConfig(to, fromValue); + } + } + } + private static void knownHosts(JSch sch, FS fs) throws JSchException { final File home = fs.userHome(); if (home == null) |