Skip to content

Commit

Permalink
Ssh: add Match keyword support (#695)
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Ranquet <[email protected]>
  • Loading branch information
granquet authored Oct 6, 2020
1 parent fd68114 commit 299979d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lenses/ssh.aug
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module Ssh =
| rekey_limit

let key_re = /[A-Za-z0-9]+/
- /SendEnv|Host|ProxyCommand|RemoteForward|LocalForward|MACs|Ciphers|(HostKey|Kex)Algorithms|PubkeyAcceptedKeyTypes|GlobalKnownHostsFile|RekeyLimit/i
- /SendEnv|Host|Match|ProxyCommand|RemoteForward|LocalForward|MACs|Ciphers|(HostKey|Kex)Algorithms|PubkeyAcceptedKeyTypes|GlobalKnownHostsFile|RekeyLimit/i


let other_entry = [ indent . key key_re
Expand All @@ -105,11 +105,26 @@ module Ssh =
let host = [ key /Host/i . spc . value_to_eol . eol . entry* ]


let condition_entry =
let value = store /[^ \t\r\n=]+/ in
[ spc . key /[A-Za-z0-9]+/ . spc . value ]

let match_cond =
[ label "Condition" . condition_entry+ . eol ]

let match_entry = entry

let match =
[ key /Match/i . match_cond
. [ label "Settings" . match_entry+ ]
]


(************************************************************************
* Group: LENS
*************************************************************************)

let lns = entry* . host*
let lns = entry* . (host | match)*

let xfm = transform lns (incl "/etc/ssh/ssh_config" .
incl (Sys.getenv("HOME") . "/.ssh/config") .
Expand Down
12 changes: 12 additions & 0 deletions lenses/tests/test_ssh.aug
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module Test_ssh =
"# start
IdentityFile /etc/ssh/identity.asc

Match final all
GSSAPIAuthentication yes

Host suse.cz
ForwardAgent yes
SendEnv LC_LANG
Expand All @@ -30,6 +33,15 @@ PubkeyAcceptedKeyTypes [email protected],ssh-ed25519,ssh-rsa-cert
{ "#comment" = "start" }
{ "IdentityFile" = "/etc/ssh/identity.asc" }
{ }
{ "Match"
{ "Condition"
{ "final" = "all" }
}
{ "Settings"
{ "GSSAPIAuthentication" = "yes" }
{ }
}
}
{ "Host" = "suse.cz"
{ "ForwardAgent" = "yes" }
{ "SendEnv"
Expand Down

0 comments on commit 299979d

Please sign in to comment.