Content-Length: 420052 | pFad | https://github.com/paramiko/paramiko/commit/5fcb8da16d4b33fa52880c1c3e848654a698d34d

93 OpenSSH docs state %C should also work in IdentityFile and Match exec · paramiko/paramiko@5fcb8da · GitHub
Skip to content

Commit 5fcb8da

Browse files
committed
OpenSSH docs state %C should also work in IdentityFile and Match exec
(at least, of what we presently ourselves support - it's also allowed in others)
1 parent 1bf3dce commit 5fcb8da

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

paramiko/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class SSHConfig(object):
6262
TOKENS_BY_CONFIG_KEY = {
6363
"controlpath": ["%C", "%h", "%l", "%L", "%n", "%p", "%r", "%u"],
6464
"hostname": ["%h"],
65-
"identityfile": ["~", "%d", "%h", "%l", "%u", "%r"],
65+
"identityfile": ["%C", "~", "%d", "%h", "%l", "%u", "%r"],
6666
"proxycommand": ["~", "%h", "%p", "%r"],
6767
# Doesn't seem worth making this 'special' for now, it will fit well
6868
# enough (no actual match-exec config key to be confused with).
69-
"match-exec": ["%d", "%h", "%L", "%l", "%n", "%p", "%r", "%u"],
69+
"match-exec": ["%C", "%d", "%h", "%L", "%l", "%n", "%p", "%r", "%u"],
7070
}
7171

7272
def __init__(self):

tests/configs/match-exec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Host target
1212
User intermediate
1313
HostName configured
1414

15-
Match exec "%d %h %L %l %n %p %r %u"
15+
Match exec "%C %d %h %L %l %n %p %r %u"
1616
Port 1337

tests/test_config.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def test_controlpath_token_expansion(self, getpass):
218218
Host explicit_host
219219
HostName ohai
220220
ControlPath remoteuser %r host %h orighost %n
221+
222+
Host hashbrowns
223+
ControlPath %C
221224
"""
222225
)
223226
result = config.lookup("explicit_user")["controlpath"]
@@ -226,6 +229,9 @@ def test_controlpath_token_expansion(self, getpass):
226229
result = config.lookup("explicit_host")["controlpath"]
227230
# Remote user falls back to local user; host and orighost may differ
228231
assert result == "remoteuser gandalf host ohai orighost explicit_host"
232+
# Supports %C
233+
result = config.lookup("hashbrowns")["controlpath"]
234+
assert result == "fc995d9f41ca1bcec7bc1d7f1ca87b9ff568a6d4"
229235

230236
def test_negation(self):
231237
config = SSHConfig.from_text(
@@ -280,7 +286,6 @@ def test_proxycommand(self):
280286
def test_identityfile(self):
281287
config = SSHConfig.from_text(
282288
"""
283-
284289
IdentityFile id_dsa0
285290
286291
Host *
@@ -291,6 +296,9 @@ def test_identityfile(self):
291296
292297
Host dsa2*
293298
IdentityFile id_dsa22
299+
300+
Host hashbrowns
301+
IdentityFile %C
294302
"""
295303
)
296304
for host, values in {
@@ -303,8 +311,15 @@ def test_identityfile(self):
303311
"hostname": "dsa22",
304312
"identityfile": ["id_dsa0", "id_dsa1", "id_dsa22"],
305313
},
314+
"hashbrowns": {
315+
"hostname": "hashbrowns",
316+
"identityfile": [
317+
"id_dsa0",
318+
"id_dsa1",
319+
"d5c0115d09912e39ff27844ea9d6052fc6048f99",
320+
],
321+
},
306322
}.items():
307-
308323
assert config.lookup(host) == values
309324

310325
def test_config_addressfamily_and_lazy_fqdn(self):
@@ -740,10 +755,10 @@ def test_does_not_match_nonzero_exit_codes(self, run):
740755
@patch("paramiko.config.getpass")
741756
@patch("paramiko.config.invoke.run")
742757
def test_tokenizes_argument(self, run, getpass, socket):
743-
socket.gethostname.return_value = "local.fqdn"
744758
getpass.getuser.return_value = "gandalf"
745-
# Actual exec value is "%d %h %L %l %n %p %r %u"
759+
# Actual exec value is "%C %d %h %L %l %n %p %r %u"
746760
parts = (
761+
"bf5ba06778434a9384ee4217e462f64888bd0cd2",
747762
expanduser("~"),
748763
"configured",
749764
"local",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/paramiko/paramiko/commit/5fcb8da16d4b33fa52880c1c3e848654a698d34d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy