bug-cfengine
[Top][All Lists]
Advanced

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

Re: DefineInGroup'd classes not really being defined?


From: Andrew Stribblehill
Subject: Re: DefineInGroup'd classes not really being defined?
Date: Tue, 13 May 2003 14:23:25 +0100
User-agent: Mutt/1.5.4i

Quoting Chip Seraphine <address@hidden> (2003-05-12 18:43:26 BST):
> 2.06, solaris/intel:
> 
> Mark pointed me at the DefineInGroup command, but I can't get it to 
> work.  -d2 shows that the code for it in edittools.c does in fact fire 
> and it tries to add the appropriate classname (string) to the heap (via 
> AddClassToHeap(currentitem)), but subsequent actions that require that 
> class do not see the class.  Running cfagent in a debugger confirms what 
> the d2 output.
> 
> Basically, the edittools stuff seems to be Doing The Right Thing but the 
> class is not defined for purposes of subsequent actions.  The *really* 
> wierd thing is that the CFALLCLASSES environment variable appears to 
> have the DefineInGroup'd class set properly in it.
> 
> Specifically, this cfagent.conf file:
> 
>    control:
> 
>        Inform                = ( on )
>        actionsequence        = ( editfiles shellcommands )
> 
>    editfiles:
>        { /tmp/foo
>            BeginGroupIfNoSuchLine "nomatching"
>                Append "appended line $(date)"
>                DefineInGroup "foo2"
>            EndGroup
>            DefineClasses "foo1"
>        }
> 
>    shellcommands:
>        "/usr/bin/logger -p local1.info running a test"
>        foo1::
>            "/usr/bin/logger -p local1.notice foo1 $(date)" 
>        foo2::
>            "/usr/bin/logger -p local1.notice foo2 $(date)"

Curiouser and curiouser (to quote Alice). When I replace the
shellcommands chunk with

alerts:
  foo1:: "foo1 defined"
  foo2:: "foo2 defined"

it works fine.

Ah, the foo2 class isn't counted as installable when the shell
command gets parsed. Verified that AddInstallable = ( foo2 ) makes it
work.

The following patch Works For Me(tm):

diff -ruN cfengine-2.0.6-old/src/install.c cfengine-2.0.6/src/install.c
--- cfengine-2.0.6-old/src/install.c    2003-04-07 18:38:31.000000000 +0100
+++ cfengine-2.0.6/src/install.c        2003-05-13 12:26:02.000000000 +0100
@@ -2735,6 +2735,7 @@
                    {
                    yyerror("DefineInGroup outside a group");
                    }
+                AddInstallable(new->data);
                 break;
         case SetLine:
                if (FOREACHLEVEL > 0)
@@ -2760,7 +2761,7 @@
         case DefineClasses:
             if (EDITGROUPLEVEL > 0 || FOREACHLEVEL > 0)
                {
-               yyerror("Class definitions inside conditionals or loops are not 
allowed");
+               yyerror("Class definitions inside conditionals or loops are not 
allowed. Did you mean DefineInGroup?");
                }
             AddInstallable(new->data);
             break;

-- 
FAEROES
NORTH OR NORTHWEST 5 OR 6, OCCASIONALLY 7 DECREASING 4 OR 5,
OCCASIONALLY 6. OCCASIONAL RAIN OR SQUALLY SHOWERS. MODERATE OR
GOOD

Attachment: pgp8Rs2G17KTj.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]