[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [augeas-devel] Problem with fai_diskconfig



On Thu, 2011-09-01 at 08:41 +0200, Raphaël Pinson wrote:
> On Thu, Sep 1, 2011 at 4:16 AM, Francis Giraldeau <
> francis giraldeau gmail com> wrote:
> 
> > Here is a little bug that ocured recently:
> >
> > glob_for_lens                  ... FAIL
> >  Match: /augeas/load/*[ '/etc/hosts/1/ipaddr' =~ glob(incl) +
> > regexp('/.*') ]/lens
> >  Expected: 1 entries
> >    /augeas/load/Hosts/lens = @Hosts
> >  Actual: 2 entries
> >    /augeas/load/Hosts/lens = @Hosts
> >    /augeas/load/FAI_DiskConfig/lens = @FAI_DiskConfig
> >
> > It seems the fai_diskconfig lens is matching more than it should? I
> > tried to figure where this file is located to add explicit incl that
> > would solve the issue, but I can't find the standard path. As a
> > temporary fix, I commented the transform. It means the lens needs to be
> > loaded manually for a specific file. Can we do a better fix?
> >
> >
> That will be my fault.

Not entirely ;) It exposed a corner case with the glob function in path
expressions: in the above match, if there are no incl nodes, glob(incl)
would produce the empty regular expression /()/ .. you can see how
things disintegrate from there.

Since this is very surprising, I changed it so that glob(incl) produces
a regular expression that never matches. That's closer to what one would
expect. The patch I just committed is:

>From 9ef150cbcf0ca29ad2d1f563ef5e6a1c555efa1f Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter redhat com>
Date: Thu, 1 Sep 2011 16:23:37 -0700
Subject: [PATCH] * src/pathx.c (nodeset_as_regexp): match nothing if nodeset
 is empty

This makes sure that constructs like 'glob(no_such_node)' or
'regexp(no_such_node)' in path expressions never match anything, which is a
better default than the empty regexp that was produced before.
---
 src/pathx.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/pathx.c b/src/pathx.c
index ca26752..1dd7992 100644
--- a/src/pathx.c
+++ b/src/pathx.c
@@ -654,7 +654,9 @@ nodeset_as_regexp(struct info *info, struct nodeset *ns, int glob) {
     }
 
     if (used == 0) {
-        result = regexp_make_empty(info);
+        /* If the nodeset is empty, make sure we produce a regexp
+         * that never matches anything */
+        result = make_regexp_unescape(info, "[^\001-\7ff]", 0);
     } else {
         if (ALLOC_N(rx, ns->used) < 0)
             goto error;
-- 
1.7.6

David




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]