Bug #2218

PT checkGenericFileContent version 2.1 is completely broken!

Added by Jonathan CLARKE about 2 years ago. Updated about 2 years ago.

Status:Released Start date:2012-01-30
Priority:1 Due date:
Assignee:Nicolas CHARLES % Done:

100%

Category:Policy Templates
Target version:Rudder - 2.3.7
Pull Request:

Description

The version 2.1 of this PT is set to be multi-instance, but the CFEngine String Template files are not.

As a result, we get a generated file with variable values all concatenated, similar to this:

"generic_file_content_path" string => "/etc/passwd/etc/group/etc/shadow";


Related issues

related to Rudder - Bug #2417: checkGenericFileContent 2.1 is highly dubious Released 2012-04-06
blocks Techniques - User story (meta) #2140: PT checkGenericFileContent : Add the possibility to delet... Released 2011-12-22

Associated revisions

Revision 5564abd8
Added by Matthieu CERDA about 2 years ago

Fixes #2218: The PT checkGenericFileContent has been repaired (version 2.1)

Revision fe8590b6
Added by Matthieu CERDA about 2 years ago

Merge branch 'branches/rudder/2.3'

  • branches/rudder/2.3:
    Fixes #2218: The PT checkGenericFileContent has been repaired (version 2.1)

Revision d9fdf128
Added by Matthieu CERDA about 2 years ago

Fixes #2218: The PT checkGenericFileContent has been repaired (version 2.1)

Revision 2bd03526
Added by Matthieu CERDA about 2 years ago

Refs #2218: TRIVIAL, cosmetic refactoring (indentation)

Revision ad0e3e49
Added by Matthieu CERDA about 2 years ago

Merge branch 'branches/rudder/2.3'

  • branches/rudder/2.3:
    Refs #2218: TRIVIAL, cosmetic refactoring (indentation)
    Fixes #2218: The PT checkGenericFileContent has been repaired (version 2.1)
    Revert "Fixes #2218: The PT checkGenericFileContent has been repaired (version 2.1)"

Revision ea8f2902
Added by Matthieu CERDA about 2 years ago

Fixes #2218: There was some extra statements forgotten during the PT repairation

Revision b584a8c2
Added by Matthieu CERDA about 2 years ago

Fixes #2218: There was some extra statements forgotten during the PT repairation

History

#1 Updated by Matthieu CERDA about 2 years ago

  • Status changed from New to Pending technical review
  • % Done changed from 0 to 100

#5 Updated by Jonathan CLARKE about 2 years ago

  • Status changed from Pending technical review to 2
  • Assignee set to Matthieu CERDA
  • % Done changed from 100 to 80

The CFEngine template now looks fine, thanks Matthieu.

However I'm not so sure about the policy.xml file. Comparing versions 2.0 and 2.1, I get the following diff, in which I notice that:
  • The "File" section is no longer multivalues. Why not?
  • Several sub-sections used to have a componentKey but no longer do. Why is this?
--- 2.0/policy.xml    2011-11-14 09:27:31.229575902 +0100
+++ 2.1/policy.xml    2012-02-01 17:53:42.524501477 +0100
@@ -37,11 +37,11 @@

   <TRACKINGVARIABLE>
     <SAMESIZEAS>GENERIC_FILE_CONTENT_PATH</SAMESIZEAS>
-  </TRACKINGVARIABLE>
-    
+</TRACKINGVARIABLE>
+
   <SECTIONS>
-    <SECTION name="File to manage" multivalued="true">
-        <SECTION name="File" multivalued="false" component="true" componentKey="GENERIC_FILE_CONTENT_PATH">
+    <SECTION name="File to manage">
+        <SECTION name="File" component="true">
           <INPUT>
             <NAME>GENERIC_FILE_CONTENT_PATH</NAME>
             <DESCRIPTION>Path</DESCRIPTION>
@@ -69,8 +69,55 @@
               <DEFAULT>false</DEFAULT>
             </CONSTRAINT>
           </SELECT1>
+                <INPUT>
+                  <NAME>GENERIC_FILE_CONTENT_DELETION_BOOLEAN</NAME>
+                  <DESCRIPTION>Enable the deletion of lines using a regexp</DESCRIPTION>
+                  <CONSTRAINT>
+                    <TYPE>boolean</TYPE>
+                    <DEFAULT>false</DEFAULT>
+                  </CONSTRAINT>
+                </INPUT>
+                <INPUT>
+                  <NAME>GENERIC_FILE_CONTENT_MODIFICATION_BOOLEAN</NAME>
+                  <DESCRIPTION>Enable the replacement of lines using a regexp</DESCRIPTION>
+                  <CONSTRAINT>
+                    <TYPE>boolean</TYPE>
+                    <DEFAULT>false</DEFAULT>
+                  </CONSTRAINT>
+                </INPUT>
         </SECTION>
-        <SECTION name="Permission adjustment" multivalued="false" component="true" componentKey="GENERIC_FILE_CONTENT_PATH">
+        <SECTION name="Line deletion regular expressions" component="true" componentKey="GENERIC_FILE_CONTENT_PATH">
+          <INPUT>
+            <NAME>GENERIC_FILE_CONTENT_DELETION_REGEXP</NAME>
+            <DESCRIPTION>Regular expression</DESCRIPTION>
+            <LONGDESCRIPTION>Regular expression used to match a line to be deleted</LONGDESCRIPTION>
+            <CONSTRAINT>
+              <TYPE>string</TYPE>
+              <DEFAULT>deleteme.*</DEFAULT>
+            </CONSTRAINT>
+          </INPUT>
+        </SECTION>
+        <SECTION name="Line replacement regular expressions" component="true" componentKey="GENERIC_FILE_CONTENT_PATH">
+          <INPUT>
+            <NAME>GENERIC_FILE_CONTENT_MODIFICATION_REGEXP</NAME>
+            <DESCRIPTION>Regular expression</DESCRIPTION>
+            <LONGDESCRIPTION>Regular expression used to match a line to be replaced</LONGDESCRIPTION>
+            <CONSTRAINT>
+              <TYPE>string</TYPE>
+              <DEFAULT>replaceme.*</DEFAULT>
+            </CONSTRAINT>
+          </INPUT>
+          <INPUT>
+            <NAME>GENERIC_FILE_CONTENT_MODIFICATION_DESTINATION</NAME>
+            <DESCRIPTION>String used as a replacement</DESCRIPTION>
+            <CONSTRAINT>
+              <TYPE>string</TYPE>
+              <DEFAULT></DEFAULT>
+              <MAYBEEMPTY>true</MAYBEEMPTY>
+            </CONSTRAINT>
+          </INPUT>
+        </SECTION>
+        <SECTION name="Permission adjustment" component="true">
             <INPUT>
                   <NAME>GENERIC_FILE_CONTENT_PERMISSION_ADJUSTMENT</NAME>
                   <DESCRIPTION>Set explicit permissions to apply on the file</DESCRIPTION>
@@ -99,7 +146,7 @@
             </CONSTRAINT>
           </INPUT>
         </SECTION>
-        <SECTION name="Post-modification hook" multivalued="false" component="true" componentKey="GENERIC_FILE_CONTENT_PATH">
+        <SECTION name="Post-modification hook" component="true">
             <INPUT>
                   <NAME>GENERIC_FILE_CONTENT_POST_HOOK_RUN</NAME>
                   <DESCRIPTION>Should the command(s) below be run if any modifications are made on the path above?</DESCRIPTION>
@@ -117,5 +164,4 @@
     </SECTION>

   </SECTIONS>
-
 </POLICY>

#6 Updated by Matthieu CERDA about 2 years ago

  • Status changed from 2 to Pending technical review
  • % Done changed from 80 to 100

#7 Updated by Matthieu CERDA about 2 years ago

You were right, some old statements from the 2.0 were not ported to this version :) All hail the technical review !

#8 Updated by Nicolas CHARLES about 2 years ago

  • Status changed from Pending technical review to In progress

Something must have gone bad, the code seems valid in branch 2.4, but not in 2.3
(commit ea8f29020bbe205615c751b180c5aaf5ece92288 is not applied on the policy.xml file)

Could you have a look at this please Matthieu ?

#9 Updated by Matthieu CERDA about 2 years ago

  • Status changed from In progress to Discussion
  • Assignee changed from Matthieu CERDA to Nicolas CHARLES

Can we please discuss this on #2417 ? I can not focus on the same discussion on two different but at a time :D

#10 Updated by Matthieu CERDA about 2 years ago

  • Status changed from Discussion to Pending technical review

#11 Updated by Nicolas CHARLES about 2 years ago

  • Status changed from Pending technical review to Released

The final correction seems valid, thank you Matthieu

Also available in: Atom PDF