[augeas-devel] Is augeas weak for sysconfig files, or missing something?

Michal Filka michal.filka at suse.cz
Wed Mar 28 07:20:36 UTC 2012


Hi,

I've started using augeas. Firstly, I wanted to use it for parsing
sysconfig like files (records in format <identifier>=<value>). I found
that current implementation of Sysconfig.lns is buggy. Some examples
processed incorrectly follows:

# should fail, but pass using Sysconfig.lns
FAIL_1='e'e'
FAIL_2='e'e'e'
FAIL_3='''
FAIL_4=' "
FAIL_5='e
FAIL_6=e'

# should pass, but fails using Sysconfig.lns
PASS_1=essid            # fails due to this comment

Some of those bugs are critical for my desired usage, so I tried to patch
it. However I got into troubles. It is possible that I'm missing something
but I thing that augeas' language is too weak to describe the file's
format properly. I'll try to explain my thoughts on simplified example.

So, lets have following definition:
module Test =

	let identifier = key /[A-Z]+/
	let value = store /[a-z]*/

	let record = [ identifier . del /=/ "=" . value ]
                      | [ identifier . del /=/ "=" . value . del "\"" "\"" ]

	let lns = record

This example won't pass parsing because of overlapping values. So I modify
it a bit:

module Test =

	let identifier = key /[A-Z]+/
	let value = store /[a-z]*/
	let dqvalue = store /[a-z ]* [a-z ]*/

	let record = [ identifier . del /=/ "=" . value ]
                      | [ identifier . del /=/ "=" . del "\"" "\"" . dqvalue
. del "\"" "\"" ]

	let lns = record

it's ok, so test it:

(*1*) 	test lns get "KEY=value" = ?
(*2*)	test lns get "KEY=\"value\"" = ?

the (*2*) won't pass (test.aug:14.6-.29:exception: Get did not match
entire input). But this is valid sysconfig syntax. I believe that it is
possible to resolve in this simplified example, but when you try to
describe real sysconfig file you get into huge troubles (add ', escaping
quotes and more). I tried to resolve that but I wasn't successful until
now.

I believe that the problem is mainly because of quoting. You can have
valid values in form: value (without quotes), "value", 'value'. If you
want to describe that in augeas you have to do something like this: let
entry = [ value ] | [ dels "\"" . value . dels "\"" ] | [ dels "'" . value
. dels "'" ]. But this will not pass through put direction when parsing
(augeas don't know which quoting to use by default). Only trick (which I
know and which is used in Sysconfig.lns) is to define required values in
value part of the patern (e.g. double quoted value has to contain space),
but this leads to ignoring valid formats in get direction (see above
example).

One possible solution is to introduce new primitive into augeas. Something
like trim RE1 RE2 -> dels RE1 . store RE2 . dels RE1 with constraint that
values deleted by dels has to match the pattern and be equal. Another
approach would be introduce "default" branch into union (|). Something
like, if you have lns = branch1 | branch2 | branch3 and some of them
overlaps, than use first one for string which satisfies more than one
branch.

If there is another solution of the above problem, please let me know.

Thank you for your help and sorry for long mail.
Michal Filka




More information about the augeas-devel mailing list