Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2512

readfile() should not error when the target does not exist during pre-eval

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.7.3, 3.7.2, 3.7.4, 3.10.0b1
    • Fix Version/s: 3.11.0
    • Component/s: Evaluation
    • Labels:
      None
    • Steps to reproduce:
      Acceptance/unit test attached

      Description

      Calling a bundle based on a set class should not evaluate when that class is not set.
      Validated that this worked in 3.6.7 and 3.7.1

      Example:

      body common control
      {
      bundlesequence => { "main" };
      }
      
      bundle agent main
      {
        classes:
            "FILE_EXISTS" expression => fileexists("/tmp/foobar");
      
        methods:
          FILE_EXISTS::
            "test" usebundle => test,
            ifvarclass => "FILE_EXISTS";
      }
      
      bundle agent test
      {
         vars:
            "foobar" slist => readstringlist("/tmp/foobar","#[^\n]*","[\n]",100,10000);
      }
      

      Output:

      [root@lsrv8021 ~]# cf-agent --version
      CFEngine Core 3.10.0b1
      [root@lsrv8021 ~]# cf-agent -Kf ./select_class.cf
         error: Function 'readfile' failed to read file: /tmp/foobar
         error: Function 'readfile' failed to read file: /tmp/foobar
         error: Function 'readfile' failed to read file: /tmp/foobar
         ....
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10038 jimis (Dimitrios Apostolou)
                Reporter:
                Sander Sander Keemink
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel