Closed ptoscano closed 4 years ago
Which version of Augeas are you using?
Which version of Augeas are you using?
It does not matter, since this happens with current git master.
I can parse your example fine with current git master.
$ augtool -I lenses/ -At "Sshd.lns incl /tmp/sshd_config" get /files/tmp/sshd_config/Match/Condition/final
/files/tmp/sshd_config/Match/Condition/final = all
I can parse your example fine with current git master.
$ augtool -I lenses/ -At "Sshd.lns incl /tmp/sshd_config" get /files/tmp/sshd_config/Match/Condition/final /files/tmp/sshd_config/Match/Condition/final = all
Yes, the Sshd lens handles it, but not the Ssh lens.
Ah, I was not aware that ssh_config
supported Match groups!
I would be interested in getting this issue fixed. I toyed with the idea on top of release-1.8.0
I'm discovering augeas, it seems to parse and generate proper ssh_config files. heavily inspired by sshd.aug
diff --git a/lenses/ssh.aug b/lenses/ssh.aug
index 3210bdd6..092b2dab 100644
--- a/lenses/ssh.aug
+++ b/lenses/ssh.aug
@@ -39,6 +39,7 @@ module Ssh =
let value_to_eol = store Rx.space_in
let value_to_spc = store Rx.no_spaces
let value_to_comma = store /[^, \t\r\n]+/
+ let sep = del /[ \t=]+/ " "
(************************************************************************
@@ -99,12 +100,26 @@ module Ssh =
let host = [ key /Host/i . spc . value_to_eol . eol . entry* ]
+ let condition_entry =
+ let value = store /[^ \t\n=]+/ in
+ [ sep . key /[A-Za-z0-9]+/ . sep . value ]
+
+ let match_cond =
+ [ label "Condition" . condition_entry+ . eol ]
+
+ let match_entry = indent . 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") .
Looks like a good start @granquet !
Could you open a PR and add tests please?
Fixed in #695
The Ssh lens cannot parse the
Match
option. A simple example is in a ssh_config.d snipped shipped in Fedora (30),/etc/ssh/ssh_config.d/05-redhat.conf
:See also the documentation for it: https://man.openbsd.org/ssh_config#Match.
The Sshd (for
sshd_config
) lens already handlesMatch
options, although it seems they are slightly different than what allowed inssh_config
.