[augeas-devel] "ins" statement in augtool can corrupt the edited file

David Lutterkort lutter at redhat.com
Wed Oct 1 23:42:53 UTC 2008


On Mon, 2008-09-29 at 11:51 +0200, Marc Fournier wrote:
> I noticed that when using the following statement in augtool, part of
> the edited file gets lost (at least when using the inifile lens):
> 
> "ins item=value <WHERE> <PATH>"
> 
> I know this is not the way "ins" should be used, but it is tempting to
> try to. 

That's a pretty bad bug inside Augeas (some more explanations below)

> Maybe augtool should catch this case and send an error to the
> user instead ? Or perhaps "ins" could also work in this sort of
> "2-in-1" mode ?

Not sure if we should have a convenient abbreviation for 'ins followed
by set' - that's a separate discussion. So far, augtool has tried to
stay fairly close to the Augeas API, but I am open to suggestions in
that direction.

> marc at lonquimay:~/src/augeas/lenses$ augtool -I .
> augtool> ins bar=baz after /files/tmp/puppet.conf/main/vardir
> augtool> save
> augtool> 

What happens is that you create a tree node 'bar=baz', but the
underlying lens does not allow nodes with that label. When Augeas goes
through the tree to recreate the file, it notices that that node is
invalid, but instead of flagging it as an error, it just stops putting
that node and its successor into the file.

I just fixed that and sent out the patch ("Complain when nodes in the
tree can not be put"); as far as I can tell, that now gives you an error
when you try to save such a tree.

David





More information about the augeas-devel mailing list