help-cfengine
[Top][All Lists]
Advanced

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

Re: Bug (and patch) in functions.c: FileExists doesn't work if passed va


From: Mark . Burgess
Subject: Re: Bug (and patch) in functions.c: FileExists doesn't work if passed variable
Date: Tue, 25 Oct 2005 12:01:29 +0200
User-agent: Internet Messaging Program (IMP) H3 (4.0.2)


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

M

Quoting Chip Seraphine <chip@trdlnk.com>:

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.






reply via email to

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