[augeas-devel] RACE and other stuff

David Lutterkort lutter at redhat.com
Wed Apr 13 17:00:11 UTC 2011


Hi Glenn,

On Wed, 2011-04-13 at 11:30 -0400, Glenn Buckholz wrote:
> reforwarding so it gets on the list. Had to subscribe.
> 
> Using the 0.8 lense for httpd. It parses correctly now. I'm through all the
> elements in the parse tree. I need a way to do global updates to all nodes
> nodes of label = x with value = y. One example would be with label =
> directive and value = StartServers. I can write a match rule that gets all
> children one level deep, but I am having difficulty getting all children
> that fit that criteria. I am new at augeas so I'm still reading the
> documentation.

You should definitely read the docs about path expressions [1] - they
are a very powerful way to search through the tree.

As an example, if you want to make sure that all Order directives are
'Order deny,allow', you can issue the following command in augtool:

        setm /files/etc/httpd/conf/httpd.conf//directive[. = 'Order']/arg . deny,allow
        save

Check that things really have changed with

        match /files/etc/httpd/conf/httpd.conf//directive[. = 'Order']/*

The 'setm' command is used to set multiple nodes at once (ordinary 'set'
will balk if you give it a path expression that matches more than one
node)

The path expression "/files/etc/httpd/conf/httpd.conf//directive[. =
'Order']/arg" roughly says 'in the subtree rooted
at /files/etc/httpd/conf/httpd.conf find all descendants (not just
children) with label "directive" and value "Order", and use their "arg"
child'

The command then goes through this set of nodes and changes the value of
each of them to 'deny,allow'

In essence, 'setm BASE SUB VALUE' finds all nodes matching the path
expression 'BASE' and does a 'set SUB VALUE' on them; i.e., SUB is
evaluated relative to the node matching BASE, not relative to the root
of the tree.

The second argument to 'setm' is '.' here meaning 'modify the nodes that
matched the first path expression directly'. You can achieve the same
thing with this 'setm' command, with a subtle difference:

        setm /files/etc/httpd/conf/httpd.conf//directive[. = 'Order'] arg deny,allow

This command would create 'arg' children with value 'deny,allow' for all
Order directives, even ones that don't have an arg child. The first
version will only muck with Order directives that already have an arg
child.

One word of caution: the httpd lens in augeas-0.8.0 doesn't
read /etc/httpd/conf/httpd.conf because of a simple oversight. That is
fixed in git, and you can use that lens with augeas-0.8.0 without any
problems.

David

[1] http://augeas.net/page/Path_expressions





More information about the augeas-devel mailing list