On 05/03/2010 04:38 PM, David Lutterkort wrote: > On Sat, 2010-05-01 at 22:07 -0700, Russell Jackson wrote: >> I've modified the freebsd service provider to use augeas (which I've also >> written ports >> for as well as the ruby bindings) to edit /etc/rc.conf (wrote a lens for it >> and is >> distributed with the port) > > Completely unrelated, but I'd love to get a copy of the lens for > upstream augeas. It would be great if you could either send it to the > augeas mailing list, or, for simplicity to me privately. >
I'm having a bit of a dilemma on this actually. The shellvars lens works
out of the box after adding /etc/rc.conf to the transformation filter;
the problem is that, in rc.conf, all values are quoted. So, the parsed
tree is mess with entries like:
/files/etc/rc.conf/foo "\"bar\""
I've been been unable to modify the stock shellvar lens so that quotes
are optional while also discarding quotes from the tree without getting
ambiguous grammer errors. I've attached the lens I have currently.
On the other hand, even though rc.conf is a sh script, it is supposed to
only have simple variable declarations with quoted values as defined by
rc.conf(5). So maybe, it is better to have a simplified lens that
doesn't permit illegal shell constructs to be present.
--
Russell A. Jackson <[email protected]>
Network Analyst
California State University, Bakersfield
module RcConf =
autoload xfm
let comment = Util.comment
let empty = Util.empty
let eol = Util.eol
let eq = Util.del_str "="
let squot = Util.del_str "'"
let dquot = Util.del_str "\""
let char = /[^\n]/
let var_name = /[A-Za-z0-9_]+/
let value = dquot . store char* . dquot
let kv_pair = [ key var_name . eq . value . eol ]
let lns = (comment | empty | kv_pair)*
let filter = incl "/etc/rc.conf"
. incl "/boot/loader.conf"
. Util.stdexcl
let xfm = transform lns filter
module Test_RcConf =
let conf = "# /etc/rc.conf
hostname=\"host.domain\"
defaultrouter=\"4.3.2.1\"
ipv4_addrs_em0=\"4.3.2.2/24\"
foo_enable=\"YES\"
foo_flags=\"-a --foobar\"
bar_enable=\"NO\"
bar_flags=\"\"
"
test RcConf.lns get conf =
{ "#comment" = "/etc/rc.conf" }
{}
{ "hostname" = "host.domain" }
{ "defaultrouter" = "4.3.2.1" }
{ "ipv4_addrs_em0" = "4.3.2.2/24" }
{}
{ "foo_enable" = "YES" }
{ "foo_flags" = "-a --foobar" }
{ "bar_enable" = "NO" }
{ "bar_flags" = "" }
signature.asc
Description: OpenPGP digital signature
