[augeas-devel] Is this a bug in Augeas?

David Lutterkort lutter at watzmann.net
Tue Jun 5 16:54:54 UTC 2018


Hi Rich,


On Tue, Jun 5, 2018 at 3:43 AM, Richard W.M. Jones <rjones at redhat.com>
wrote:

> On Mon, Jun 04, 2018 at 11:30:52AM -0700, David Lutterkort wrote:
> > I've opened a PR (https://github.com/hercules-team/augeas/pull/562)
> with a
> > modified Grub lens that is more tolerant of these kinds of errors. Lines
> > like the 'acpi=off' in your example will now be mapped into the tree as
> > '#error' nodes, rather than refusing to parse such a file outright. Let
> me
> > know if that does what you need it to do, or if it needs to be changed
> > further.
>
> I tried to test this, but I couldn't get augtool to do anything when
> run from the local tree.
>

The easiest way to test this is to put the modified grub.aug somewhere (say
/tmp) and the
grub.conf you want to try it out with somewhere else (say, also /tmp) and
then run

    augtool -I /tmp -At 'Grub.lns incl /tmp/grub.conf'

(that's a capital i as the first option and lets you pass dirs to load
lenses from)


> After patching my git copy of augeas with the patch above and
> compiling it, augtool could never load any files:
>
>   $ PATH=`pwd`/src:$PATH LENS_DIR=`pwd`/lenses augtool -r /var/tmp/root/
>   augtool> ls /files
>   [nothing]
>

The environment variable to add dirs to the lens search path is called
AUGEAS_LENS_LIB,
but '-I' will have the same effect.


> Even without the -r parameter it did nothing.
>
> In libvirt & libguestfs we generate a ‘./run’ script in the top build
> directory which sets up the environment right so you could do
> something like:
>
>   $ ./run augtool [...]
>
> and have it just do the right thing.
>
> Anyway if I understand the proposed patch from reading the source, it
> wouldn't fail to parse the original file (which is progress) however
> if we rewrote the file then any unparsable lines would be deleted, is
> that correct?


The bad lines will show up in the tree as '#error' nodes; as long as you
leave them in the tree,
they will be preserved and show up in the output again. As an example (I
have the modified grub.aug
in $PWD/lenses/grub.aug):

> cat /tmp/grub.conf
timeout=5
acpi=off
default=0

> augtool -I lenses/ -At 'Grub.lns incl /tmp/grub.conf' set
/files/tmp/grub.conf/timeout 7
Saved 1 file(s)

> cat /tmp/grub.conf
timeout=7
acpi=off
default=0

If you want to remove bad lines explicitly, you can do:

> augtool -I lenses/ -At 'Grub.lns incl /tmp/grub.conf' rm
/files/tmp/grub.conf/#error
rm : /files/tmp/grub.conf/#error 1
Saved 1 file(s)

> cat /tmp/grub.conf
timeout=7
default=0

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20180605/d1a6ba9b/attachment.htm>


More information about the augeas-devel mailing list