Bug 975412 - inspection: Augeas expressions are broken with augeas >= 0.10
Summary: inspection: Augeas expressions are broken with augeas >= 0.10
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 975377
TreeView+ depends on / blocked
 
Reported: 2013-06-18 12:26 UTC by Richard W.M. Jones
Modified: 2013-06-18 18:32 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-06-18 16:31:38 UTC
Embargoed:


Attachments (Terms of Use)
inspection-augeas-fail.sh (476 bytes, application/x-shellscript)
2013-06-18 12:26 UTC, Richard W.M. Jones
no flags Details

Description Richard W.M. Jones 2013-06-18 12:26:10 UTC
Created attachment 762468 [details]
inspection-augeas-fail.sh

Description of problem:

(Thanks Dominic Cleal for diagnosing this one)

libguestfs currently uses an Augeas expression to limit the
files that get loaded (so Augeas doesn't run out of memory and
cause a DoS when we try to inspect weird guests).  At the
moment what we do is roughly this:

  aug_init ('/', AUG_NO_LOAD)
  aug_rm '/augeas/load//incl[. != "/etc/sysconfig/network"]'
  aug_load

which causes Augeas not to autoload any files, then to delete
all rules which DON'T match the file of interest, then to
proceed with the load.

However in Augeas >= 0.10 'incl' expressions could be globs.
Since the incl expression for /etc/sysconfig/network is a glob,
the above code which does an exact match no longer works.

After discussion we came up with an alternative expression
which works:

/augeas/load/*["/etc/sysconfig/network/" !~ regexp('^') + glob(incl) + regexp('/.*')]

Version-Release number of selected component (if applicable):

libguestfs at least as far back as 1.16 and probably further,
when used with augeas >= 0.10.

How reproducible:

100%

Steps to Reproduce:
1. Run the attached script.

Actual results:

If augeas >= 0.10 (we're not sure the precise version) is installed
then it'll print "unknown" at the end:

$ /tmp/inspection-augeas-fail.sh 
/dev/sda1
unknown      <----

That means it failed to get the hostname.

Expected results:

It should print:

/dev/sda1
foobar

Additional info:

Test program demonstrating incorrect use of Augeas:
https://bugzilla.redhat.com/attachment.cgi?id=762465

Similar code in puppet:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/augeas/augeas.rb#L176

Upstream change:
https://www.redhat.com/archives/augeas-devel/2011-May/msg00009.html

Documentation for path expressions:
https://github.com/hercules-team/augeas/wiki/Path-expressions

Comment 2 Richard W.M. Jones 2013-06-18 17:02:08 UTC
Correction:
https://github.com/libguestfs/libguestfs/commit/0ff0454c59ae79d47fadcc4f2837e3bfca7af105
is also needed for enhanced tests.

Comment 3 Richard W.M. Jones 2013-06-18 18:32:46 UTC
And another one:
https://github.com/libguestfs/libguestfs/commit/d88f6c0ba62d65acf8db074d33109947907ec048
needed for enhanced tests.


Note You need to log in before you can comment on or make changes to this bug.