This bug has already been fixed. Please go to svn for patch

M

Quoting Chip Seraphine <[EMAIL PROTECTED]>:

In 2.1.16, the FileExists() function does not work properly if passed a string with a variable in it. This is because the HandleStatInfo function passes an unexpanded string (which can contain a $(variable)) to lstat.

I was able to make it work by passing lstat(2) the expanded values generated by FunctionArgs() rather than the raw args value. This change causes FileExists to work correctly with variables in its argument list. (See attached patch, which is against current snashot from the website).

Note that HandleStatInfo did not change between .15 and .16; the change appears to be in what is set by FunctionArgs() (which was largely rewritten). A proper bug fix should probably be in FunctionArgs(), not what I have below-- this patch is a demonstration. But since my C coding is mediocre at best, I'll leave an analysis of FunctionArgs to the smart people.... :)

--

As an example of what I am talking about, the code below did not work in 2.1.16 without this patch:


#File cf.file1
control:
   path= ( /etc )
   actionsequence= ( shellcommands )

shellcommands:
   "/bin/echo here I am"
import:
     cf.file2



#File cf.file2
groups:
   passwdfile_exists= ( FileExists(${path}/passwd) )

control:
  alerts:
   foo|!foo::
      "path is ${path}"

   passwdfile_exists::  "Found it"
   !passwdfile_exists:: "Did not find it"


--

After applying the attached patch, it worked fine.






----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




_______________________________________________
Bug-cfengine mailing list
Bug-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cfengine

Reply via email to