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

Re-align class that indicates policy run was triggered from cf-execd

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.10.0
    • Component/s: None
    • Labels:
      None

      Description

      In cf-execd/cf-execd-runner.c cf-execd scans exec_command looking to see if the class from_cfexecd is defined by searching for -Dfrom_cfexecd. If it is not found it is appended to exec_command.

      if (strlen(config->exec_command) > 0)
      {
          strlcpy(cmd, config->exec_command, CF_BUFSIZE);
      
          if (!strstr(cmd, "-Dfrom_cfexecd"))
          {
              strcat(cmd, " -Dfrom_cfexecd");
          }
      }
      

      It seems the MPF got out of sync with the code in that regard. In the MPF we explicitly define cf_execd_initiated

      https://github.com/cfengine/masterfiles/blob/45119a2dbb20e9edb3bc448d67d5897cccef3d75/controls/cf_execd.cf#L41

      windows::
        exec_command => "$(sys.cf_agent) -f \"$(sys.update_policy_path)\" & $(sys.cf_agent) -Dcf_execd_initiated";
      
      !windows::
        exec_command => "$(sys.cf_agent) -f \"$(sys.update_policy_path)\" ; $(sys.cf_agent) -Dcf_execd_initiated";
      

      It is useful for cf-agent to know if it was executed as a scheduled run from cf-execd but there are 2 issues.

      1. The update policy is neglected. It doesn't know if it was executed from cf-execd. We should make sure the update policy is run and has a class defined indicating it was run from cf-execd.
      2. The class used to identify the run is not consistent between the MPF and core.
        • Searching the master branch of the MPF I found 0 instances of the string from_cfexecd.
        • Searching the master branch of the MPF I found 6 instances of cf_execd_initiated. All are used in exec_command in body executor control from cf_execd.cf
        • Searching 3.6.x , 3.7.x, 3.8.x, and 3.9.x branches of masterfiles did not show any different usage of either class within the framework.

        Attachments

          Activity

            People

            • Assignee:
              a10038 jimis (Dimitrios Apostolou)
              Reporter:
              a10042 Nick Anderson
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel