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

Extend well known paths (lib/paths.cf) without modifying vendored policy

    XMLWordPrintable

    Details

      Description

      We maintain a list of well-known paths in bundle common paths from lib/paths.cf. It will never be exhaustive. Without support for leveraging functionality like $PATH () it would be nice to be able to extend the variables defined in lib/paths.cf without having to modify the vendored policy.

      Extend paths by tagging variables

      This snippet illustrates a way that users could define their own variables tagged with paths.cf. Those variables could then be pulled in to bundle common paths.

      bundle agent __main__{}
      bundle agent extension
      {
        vars:
          # given constraints, seems ok
          any::
           "path[true]" string => "/bin/true", meta => { "paths.cf" };
      
      }
      bundle agent extension2
      {
          vars:
           "path[bin-true]" string => "/bin/true", meta => { "paths.cf" };
      }
      bundle common paths
      {
        vars:
          # blah blah, all the standard paths stuff, then at the bottom....
          "extended_path_data" data => variablesmatching_as_data( ".*", "paths.cf" );
          "_i" slist => getindices( extended_path_data );
      
          "path[$(with)]"
            string => "$(extended_path_data[$(_i)])",
            with => canonify( regex_replace( $(_i), ".*\[(.*)\]", "$1", "") );
      } 
      
      Variable name                            Variable value                                               Meta tags                               
      default:paths._i                          {"default:extension.path[true]","default:extension2.path[bin-true]"} source=promise                          
      default:paths.extended_path_data         {"default:extension.path[true]":"/bin/true","default:extension2.path[bin-true]":"/bin/true"} source=promise                          
      default:paths.path[bin_true]             /bin/true                                                    source=promise                          
      default:paths.path[true]                 /bin/true                                                    source=promise                          

      Plausibly we would need to add paths to the bundlesequence before services_autorun in order to resolve the variables from the custom policy that might have been resolved after bundle common paths was first resolved.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel