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

Reporting bug behind "set_variable_values()"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Unconfirmed
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      A long-standing minor annoyance. Although "set_variable_values()" is generally very good at maintaining a configuration file containing "key=value" lines, there is erroneous reporting if the value contains a comma (e.g. "key=two,things").

      Here's a demonstration case:

      <pre>
      #

      1. CFEngine test bundle for reporting bug from "set_variable_values".
        #
      2. Present in 3.6.1 and 3.6.5 (community edition), but also witnessed long before.
        #
      3. Use library-supplied "set_variable_values(...)" to maintain a "key=value"
      4. line into a configuration file. This is known to work well in general.
      5. After convergence, the bundle should do nothing and be silent.
        #
      6. But when the "value" contains a comma, although no editing is done (correct)
      7. two lines of report are produced (incorrect).

      body common control
      {
      bundlesequence =>

      { "test" }

      ;

      inputs =>

      { "/var/cfengine/inputs/lib/3.6/files.cf", }

      ;
      }

      bundle agent test
      {
      vars:
      any::

      1. config file
        "conffile" string => "/tmp/foo.conf";
      1. config details (file format: LHS=RHS)
      2. With a simple value this is silent after convergence.
      3. With an embedded comma, it remains chatty even after convergence.
        "confdata[TESTKEY]" string => "simple1,simple2";

      files:
      any::
      "$(conffile)"
      edit_line => set_variable_values("$(this.bundle).confdata");
      }
      </pre>

      Even after convergence, each run of "cf-agent -KI ..." reports:
      <pre>
      ...info: /default/test/files/'/tmp/foo.conf'/default/set_variable_values/field_edits/'\s:TESTKEY\s:=.:'[0]: Setting field sub-value 'simple1,simple2' in '/tmp/foo.conf'
      ...info: /default/test/files/'/tmp/foo.conf'/default/set_variable_values/field_edits/'\s:TESTKEY\s:=.:'[0]: Edited field inside file object /tmp/foo.conf
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              a10040 Kristian Amlie
              Reporter:
              davidlee David Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: