George, I promise to address this within a week

Mark

George Popescu wrote:
> Hello,
>     So I took a closer look at the output and decided to take a crack at
> a solution. Below is a patch - please excuse the ugly code, I'm not a
> developer nor have I touched C in years, so it definitely needs to be
> audited. Essentially what it does is when a method reads in the values
> for it's arguments, it scans the Macro hash table for variable values
> containing references to the argument and expands them. It compiled and
> ran fine for me, but I'm not sure what sort of criteria you test
> against. Again, thanks for the awesome app!
> 
> --George
> 
> =========================================================================================
> --- methods.c.orig      2007-07-24 13:49:50.000000000 -0500
> +++ methods.c   2007-07-24 21:06:21.000000000 -0500
> @@ -1022,6 +1022,29 @@
>                  {
>                  Verbose("Setting transmitted variable %s = ( %s
> )\n",METHODARGV[argnum],argbuf);
>                  AddMacroValue(CONTEXTID,METHODARGV[argnum],argbuf);
> +//------------------------------------------------------------------------------
> +                int count;
> +                struct cfObject *fixme;
> +                char **tbl, valstr[CF_EXPANDSIZE], exp[CF_EXPANDSIZE],
> wbraces[CF_EXPANDSIZE], wparends[CF_EXPANDSIZE], *varname, *varval;
> +
> +                fixme = ObjectContext(CONTEXTID);
> +                tbl = fixme->hashtable;
> +                snprintf(wbraces,CF_BUFSIZE,"${%s}",METHODARGV[argnum]);
> +                snprintf(wparends,CF_BUFSIZE,"$(%s)",METHODARGV[argnum]);
> +
> +                for (count = 0; count < CF_HASHTABLESIZE; count++)
> +                   {          
> +                   snprintf(valstr,CF_BUFSIZE,"%s",tbl[count]);
> +                   if ( strstr(valstr, wbraces) || strstr(valstr,
> wparends) )
> +                      {
> +                      ExpandVarstring(valstr,exp,NULL);
> +                      varname = strtok( exp, "=" );
> +                      varval = strtok( NULL, "=" );
> +                      DeleteMacro(CONTEXTID,varname);
> +                      AddMacroValue(CONTEXTID,varname,varval);
> +                      }
> +                   }
> +//------------------------------------------------------------------------------
>                  }
>               else
>                  {
> =========================================================================================
> 
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] on behalf
> of George Popescu
> Sent: Fri 7/20/2007 10:00 PM
> To: Mark Burgess
> Cc: [email protected]
> Subject: RE: Cfengine variable expansion problem.
> 
> Hello,
>     I just wanted to follow up with info that should be a little more
> useful than my last reply. Attached are the current versions (I've made
> a few changes during my attempts to get it to parse correctly) of the
> relevant files, and the "-d2" output of a cfagent run in the file
> "baby1run.out". The following two excerpts from the "-d2" output seem
> most relevant to the issue:
> 
> ------------------------------------------------------------------------------------------
> Scanning variable site_in
> GetMacroValue(private-method,site_in)
> GetMacroValue(private-method,site_in): using scope 'private-method' for
> variable 'site_in'
> Currently non existent variable $(site_in)
> Returning varstring (${site_in})
> AddMacroValue(private-method.long_sname=${site_in})
> ExpandVarstring( ${site_in} )
> Add || to str, waiting at |${site_in}|
> ExtractOuterVarString(${site_in}) - syntax verify
> Extracted outer variable |${site_in}|
> Returning substring value site_in
> Scanning variable site_in
> GetMacroValue(private-method,site_in)
> GetMacroValue(private-method,site_in): using scope 'private-method' for
> variable 'site_in'
> Currently non existent variable $(site_in)
> Returning varstring (${site_in})
> Added Macro at hash address 1018 to object private-method with value
> long_sname=${site_in}
> ------------------------------------------------------------------------------------------
> 
> and then later on,
> 
> ------------------------------------------------------------------------------------------
> DEFINED MACRO/VARIABLES (by contexts)
> OBJECT: global
>    1895 : ipv4[eth1]=192.168.95.131
> OBJECT: main
> OBJECT: private-method
>    1018 : long_sname=${site_in}
>    2086 : confname=inc.${site_in}.conf
>    2245 : site_in=newsite3.family.org
>    2276 : short_sname=
>    2323 : cfdir=/var/lib/cfengine2
>    4514 : docroot=/var/www/${site_in}
> ------------------------------------------------------------------------------------------
> 
> I'm not sure if another pass through the macro table to expand variables
> would be the solution, or if I just wrote my method wrong. Thanks for
> the awesome program by the way!
> 
> --George
> 
> -----Original Message-----
> From: Mark Burgess [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 20, 2007 1:34 AM
> To: George Popescu
> Cc: [email protected]
> Subject: Re: Cfengine variable expansion problem.
> 
> 
> Have you tried putting quotes around the variables?
> 
> Method("$variable")
> 
> I use this all the time....
> 
> 
> control:
> 
>   workfile   = ( "/tmp/chain-pattern" )
> 
> ##########################################################
> 
> methods:
> 
>   #
>   # Pattern has to be coded in classes (from) and servers (to)
>   #
> 
> node1|node2::               # U(p) | p - binding
> 
>   Aggregate("$(workfile)")
> 
>      server=node2
>      action=method_pattern.cf
>      returnvars=ret
>      returnclasses=chain_link
> 
> node2|node3::
> 
>   Aggregate("$(workfile)")
> 
>      server=node3
>      action=method_pattern.cf
>      returnvars=ret
>      returnclasses=chain_link
> 
> 
> George Popescu wrote:
>> So I wanted to try out methods and wrote a quick config. These same
>> configuration lines below causes glibc free and segmentation fault
>> errors when run on the 2.1.20-1 build for Ubuntu 7.04, so I downloaded
>> and built 2.2.1, which runs, but doesn't properly expand variables.
>>
>> 
>>
>> ############# The relevant parts of the cfagent.conf file
> #################
>>
> [snip]
> 
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.10.10/908 - Release Date:
> 7/19/2007 6:10 PM
> 
>            
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.10.10/908 - Release Date:
> 7/19/2007 6:10 PM
> 
>              
> 
> 

-- 
Mark Burgess

Professor of Network and System Administration
Oslo University College

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  [EMAIL PROTECTED]
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to