diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2021-11-13 13:08:14 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-11-15 22:26:19 +0100 |
commit | c4b3ec72faf891120fdd93246503d0bee339f349 (patch) | |
tree | fc62c7e16b4fa33cee7f3b84f950cac5e0746d5b | |
parent | 2adbf91d8fbbc9ce7ee391e8072591d5d1b7fd01 (diff) | |
download | jgit-c4b3ec72faf891120fdd93246503d0bee339f349.tar.gz jgit-c4b3ec72faf891120fdd93246503d0bee339f349.zip |
OpenSshConfigFile: update token replacements
It appears that the OpenSSH documentation[1] has changed; it now allows
more flags for a number of keys.
[1] https://man.openbsd.org/ssh_config.5#TOKENS
Change-Id: I55df174f86a3fd4a6ef22687dc433ac9f9ad181d
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java index 4cffcc5ddf..4d1864a92c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java @@ -767,13 +767,15 @@ public class OpenSshConfigFile implements SshConfigStore { List<String> values = multiOptions .get(SshConstants.IDENTITY_FILE); if (values != null) { - values = substitute(values, "dhlru", r, true); //$NON-NLS-1$ + values = substitute(values, Replacer.DEFAULT_TOKENS, r, + true); values = replaceTilde(values, home); multiOptions.put(SshConstants.IDENTITY_FILE, values); } values = multiOptions.get(SshConstants.CERTIFICATE_FILE); if (values != null) { - values = substitute(values, "dhlru", r, true); //$NON-NLS-1$ + values = substitute(values, Replacer.DEFAULT_TOKENS, r, + true); values = replaceTilde(values, home); multiOptions.put(SshConstants.CERTIFICATE_FILE, values); } @@ -782,6 +784,8 @@ public class OpenSshConfigFile implements SshConfigStore { List<String> values = listOptions .get(SshConstants.USER_KNOWN_HOSTS_FILE); if (values != null) { + values = substitute(values, Replacer.DEFAULT_TOKENS, r, + true); values = replaceTilde(values, home); listOptions.put(SshConstants.USER_KNOWN_HOSTS_FILE, values); } @@ -790,29 +794,29 @@ public class OpenSshConfigFile implements SshConfigStore { // HOSTNAME already done above String value = options.get(SshConstants.IDENTITY_AGENT); if (value != null) { - value = r.substitute(value, "dhlru", true); //$NON-NLS-1$ + value = r.substitute(value, Replacer.DEFAULT_TOKENS, true); value = toFile(value, home).getPath(); options.put(SshConstants.IDENTITY_AGENT, value); } value = options.get(SshConstants.CONTROL_PATH); if (value != null) { - value = r.substitute(value, "ChLlnpru", true); //$NON-NLS-1$ + value = r.substitute(value, Replacer.DEFAULT_TOKENS, true); value = toFile(value, home).getPath(); options.put(SshConstants.CONTROL_PATH, value); } value = options.get(SshConstants.LOCAL_COMMAND); if (value != null) { - value = r.substitute(value, "CdhlnprTu", false); //$NON-NLS-1$ + value = r.substitute(value, "CdhLlnprTu", false); //$NON-NLS-1$ options.put(SshConstants.LOCAL_COMMAND, value); } value = options.get(SshConstants.REMOTE_COMMAND); if (value != null) { - value = r.substitute(value, "Cdhlnpru", false); //$NON-NLS-1$ + value = r.substitute(value, Replacer.DEFAULT_TOKENS, false); options.put(SshConstants.REMOTE_COMMAND, value); } value = options.get(SshConstants.PROXY_COMMAND); if (value != null) { - value = r.substitute(value, "hpr", false); //$NON-NLS-1$ + value = r.substitute(value, "hnpr", false); //$NON-NLS-1$ options.put(SshConstants.PROXY_COMMAND, value); } } @@ -880,6 +884,15 @@ public class OpenSshConfigFile implements SshConfigStore { } private static class Replacer { + + /** + * Tokens applicable to most keys. + * + * @see <a href="https://man.openbsd.org/ssh_config.5#TOKENS">man + * ssh_config</a> + */ + public static final String DEFAULT_TOKENS = "CdhLlnpru"; //$NON-NLS-1$ + private final Map<Character, String> replacements = new HashMap<>(); public Replacer(String host, int port, String user, |