diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2019-12-03 14:04:00 -0500 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2019-12-03 14:04:00 -0500 |
commit | 84fa355a253d30d6c39adaea8bb095ced0c3b751 (patch) | |
tree | dda481f679fbd57b7a1760dfa42903b5a9e58b59 /paramiko/config.py | |
parent | 8ce1e4c36c43363dcc5964daaf6e06754bf12cc2 (diff) | |
download | paramiko-84fa355a253d30d6c39adaea8bb095ced0c3b751.tar.gz |
Apply %h tokenization to HostName
This was another spot that incidentally occurred in older (and moved)
code, but was made incorrect after cleanup
Diffstat (limited to 'paramiko/config.py')
-rw-r--r-- | paramiko/config.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index bef42610..e6877d01 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -60,6 +60,7 @@ class SSHConfig(object): # compatible across the board, e.g. OpenSSH 8.1 added %n to ProxyCommand. TOKENS_BY_CONFIG_KEY = { "controlpath": ["%h", "%l", "%L", "%n", "%p", "%r", "%u"], + "hostname": ["%h"], "identityfile": ["~", "%d", "%h", "%l", "%u", "%r"], "proxycommand": ["~", "%h", "%p", "%r"], # Doesn't seem worth making this 'special' for now, it will fit well @@ -412,13 +413,12 @@ class SSHConfig(object): # Short-circuit if no tokenization possible if not allowed_tokens: return value - # Obtain potentially configured (and even possibly itself tokenized) - # hostname, for use with %h in other values. + # Obtain potentially configured hostname, for use with %h. + # Special-case where we are tokenizing the hostname itself, to avoid + # replacing %h with a %h-bearing value, etc. configured_hostname = target_hostname - if "hostname" in config: - configured_hostname = config["hostname"].replace( - "%h", target_hostname - ) + if key != "hostname": + configured_hostname = config.get("hostname", configured_hostname) # Ditto the rest of the source values if "port" in config: port = config["port"] |