bug-cfengine
[Top][All Lists]
Advanced

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

Re: Alert class bug


From: Mark Burgess
Subject: Re: Alert class bug
Date: Thu, 22 Sep 2005 07:28:51 +0200

Thanks, I shall look at your patch and see if it is the correct
solution.

M

On Wed, 2005-09-21 at 21:56 -0400, Jason Kim wrote:
> This one drove me nuts...
> 
> This is what I was trying without success (culled from a post in the 
> help-cfengine list):
> 
> ++++++
> #!/usr/sbin/cfagent -qKf
> 
> control:
>     actionsequence = ( shellcommands )
> 
> shellcommands:
>     !preserved::
>         "/bin/echo setting a class"
>             define=create_preserved
>     preserved::
>         "/bin/echo preserved set"
>             define=remove_preserved
> 
> alerts:
>     create_preserved::
>         SetState("preserved",999,Preserve)
>     remove_preserved::
>         UnsetState(preserved)
> ++++++
> 
> The outcome should be this:
> address@hidden ~]# ./preserve
> cfengine::/bin/echo setti: setting a class
> address@hidden ~]# ./preserve
> cfengine::/bin/echo prese: preserved set
> address@hidden ~]# ./preserve
> cfengine::/bin/echo setti: setting a class
> 
> But instead I got this:
> address@hidden ~]# ./preserve
> cfengine::/bin/echo setti: setting a class
> address@hidden ~]# ./preserve
> cfengine::/bin/echo setti: setting a class
> 
> Using AddInstallable didn't help. If I used a plain string instead of 
> SetState/UnsetState it would issue an alert as expected.
> 
> Much debugging ensued... Apparently, during the parsing stage, when cfengine 
> encounters a function it passes it to HandleFunctionObject in parse.c. This 
> then calls IsDefinedClass to see if the class the function was parsed in is 
> defined. Unfortunately the class isn't defined at parse time because it's set 
> by shellcommands, and the list that IsDefinedClass consults apparently 
> doesn't contain the AddInstallable classes. No such class check is done if a 
> string is used instead of a function.
> 
> I've attached a trivial patch that simply ignores the IsDefinedClass check if 
> the ACTION being parsed is 'alerts'. I'm not too sure if this is the 'right' 
> fix, or if it would be better to make IsDefinedClass check a full list of 
> classes including the AddInstallable ones, but since it's a pretty heavily 
> used function I left it alone. Anyone who knows better can yell at me though.
> 
> -JayKim
> _______________________________________________
> Bug-cfengine mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-cfengine





reply via email to

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