Re: Problems while upgrading to latest cfengine-community LTS
"'Nick Anderson' via help-cfengine" <[email protected]> Tue, 23 Dec 2025 09:29:50 -0600
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain; charset="UTF-8" Respond to Berthold Cogel <[email protected]>: Re: [help-cfengine] Problems while upgrading to latest cfengine-community LTS :email: ============================================================================================================================= Hey Berthold, That seems like it's related to this blog post about change in behavior for `findfiles()' (<https://cfengine.com/blog/2025/change-in-behavior-findfiles/>). But, that post doesn't mention any intent to alter the trailing slash that signals directory. I am not sure if it was intentional or not. - Old Behavior (<= 3.23.0): When findfiles("path/*/") is used, the returned file list included the trailing slash (e.g., /path/to/dir/). - New Behavior (>= 3.24.0): The trailing slash is stripped from the returned file list (e.g., /path/to/dir), causing mismatches when compared against lists that expect the trailing slash. This policy demonstrates the difference: ,---- | bundle agent main | { | methods: | "init"; | "test"; | "check"; | reports: | inform_mode:: | "CFEngine: $(sys.cf_version)"; | } | | bundle agent init | { | vars: | "testdir" string => "/tmp/testdir"; | "subdirs" slist => { "a", "b", "c" }; | | files: | "$(testdir)/$(subdirs)/." create => "true"; | } | | bundle agent test | { | vars: | "found" | slist => { findfiles( "$(init.testdir)/*/" ) }; | | } | | bundle agent check | { | vars: | "foundtype[$(test.found)]" | string => filestat( $(test.found), "type"); | | "found_types" | slist => getvalues( foundtype ); | | "founddir[$(test.found)]" | string => "$(foundtype[$(test.found)])", | if => strcmp( "$(foundtype[$(test.found)])", "directory" ); | | "found_dirs" | slist => getindices( founddir ); | | classes: | "every_finding_has_trailing_slash" | expression => every( ".*\/$", @(test.found) ); | | "every_finding_is_directory" | expression => every( "directory", @(found_types) ); | | "every_found_directory_ends_trailing_slash" | expression => every( ".*\/$", @(found_dirs) ); | | reports: | "Every findfiles() result has trailing slash" | if => "every_finding_has_trailing_slash"; | | "Found: $(test.found)"; | | "Every findfiles() result is a directory" | if => "every_finding_is_directory"; | | "Type $(test.found) = $(foundtype[$(test.found)])"; | | "Every directory returned by findfiles() has trailing slash" | if => "every_found_directory_ends_trailing_slash"; | } `---- ,---- | # cf-agent -Kf ./t.cf --inform | R: Every findfiles() result has trailing slash | R: Found: /tmp/testdir/a/ | R: Found: /tmp/testdir/b/ | R: Found: /tmp/testdir/c/ | R: Every findfiles() result is a directory | R: Type /tmp/testdir/a/ = directory | R: Type /tmp/testdir/b/ = directory | R: Type /tmp/testdir/c/ = directory | R: Every directory returned by findfiles() has trailing slash | R: CFEngine: 3.21.8 `---- ,---- | # cf-agent -KIf ./t.cf | info: Created directory '/tmp/testdir/a/.', mode 0700 | info: Created directory '/tmp/testdir/b/.', mode 0700 | info: Created directory '/tmp/testdir/c/.', mode 0700 | R: Found: /tmp/testdir/a | R: Found: /tmp/testdir/b | R: Found: /tmp/testdir/c | R: Every findfiles() result is a directory | R: Type /tmp/testdir/a = directory | R: Type /tmp/testdir/b = directory | R: Type /tmp/testdir/c = directory | R: CFEngine: 3.24.0 `---- -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/877bud9pwl.fsf%40northern.tech. --==-=-= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <p> Hey Berthold, </p> <p> That seems like it's related to this blog post about change in behavior for= <code>findfiles()</code> (<a href=3D"https://cfengine.com/blog/2025/change= -in-behavior-findfiles/">https://cfengine.com/blog/2025/change-in-behavior-= findfiles/</a>). </p> <p> But, that post doesn't mention any intent to alter the trailing slash that = signals directory. I am not sure if it was intentional or not. </p> <ul class=3D"org-ul"> <li>Old Behavior (<=3D 3.23.0): When findfiles("path/*/") is used, the r= eturned file list included the trailing slash (e.g., <i>path/to/dir</i>).</= li> <li>New Behavior (>=3D 3.24.0): The trailing slash is stripped from the = returned file list (e.g., /path/to/dir), causing mismatches when compared a= gainst lists that expect the trailing slash.</li> </ul> <p> This policy demonstrates the difference: </p> <div class=3D"org-src-container"> <pre class=3D"src src-cfengine3"><span style=3D"color: #a89984; font-weight= : bold;">bundle</span> <span style=3D"color: #458588; font-weight: bold;">a= gent</span> <span style=3D"color: #458588;">main</span> <span style=3D"color: #689d6a;">{</span> <span style=3D"color: #a89984; font-weight: bold;">methods</span>: <span style=3D"color: #689d6a;">"init"</span>; <span style=3D"color: #689d6a;">"test"</span>; <span style=3D"color: #689d6a;">"check"</span>; <span style=3D"color: #a89984; font-weight: bold;">reports</span>: <span style=3D"color: #98971a; font-weight: bold;">inform_mode</span>:: <span style=3D"color: #689d6a;">"CFEngine: $(sys.cf_version)"</span>; <span style=3D"color: #689d6a;">}</span> <span style=3D"color: #a89984; font-weight: bold;">bundle</span> <span styl= e=3D"color: #458588; font-weight: bold;">agent</span> <span style=3D"color:= #458588;">init</span> <span style=3D"color: #689d6a;">{</span> <span style=3D"color: #a89984; font-weight: bold;">vars</span>: <span style=3D"color: #689d6a;">"testdir"</span> <span style=3D"color= : #d79921;">string</span> =3D> <span style=3D"color: #689d6a;">"/tmp/tes= tdir"</span>; <span style=3D"color: #689d6a;">"subdirs"</span> <span style=3D"color= : #d79921;">slist</span> =3D> <span style=3D"color: #d79921;">{</span> <= span style=3D"color: #689d6a;">"a"</span>, <span style=3D"color: #689d6a;">= "b"</span>, <span style=3D"color: #689d6a;">"c"</span> <span style=3D"color= : #d79921;">}</span>; <span style=3D"color: #a89984; font-weight: bold;">files</span>: <span style=3D"color: #689d6a;">"$(testdir)/$(subdirs)/."</span> crea= te =3D> <span style=3D"color: #689d6a;">"true"</span>; <span style=3D"color: #689d6a;">}</span> <span style=3D"color: #a89984; font-weight: bold;">bundle</span> <span styl= e=3D"color: #458588; font-weight: bold;">agent</span> <span style=3D"color:= #458588;">test</span> <span style=3D"color: #689d6a;">{</span> <span style=3D"color: #a89984; font-weight: bold;">vars</span>: <span style=3D"color: #689d6a;">"found"</span> <span style=3D"color: #d79921;">slist</span> =3D> <span style=3D= "color: #d79921;">{</span> findfiles<span style=3D"color: #458588;">(</span= > <span style=3D"color: #689d6a;">"$(init.testdir)/*/"</span> <span style= =3D"color: #458588;">)</span> <span style=3D"color: #d79921;">}</span>; <span style=3D"color: #689d6a;">}</span> <span style=3D"color: #a89984; font-weight: bold;">bundle</span> <span styl= e=3D"color: #458588; font-weight: bold;">agent</span> <span style=3D"color:= #458588;">check</span> <span style=3D"color: #689d6a;">{</span> <span style=3D"color: #a89984; font-weight: bold;">vars</span>: <span style=3D"color: #689d6a;">"foundtype[$(test.found)]"</span> <span style=3D"color: #d79921;">string</span> =3D> filestat<span= style=3D"color: #d79921;">(</span> $<span style=3D"color: #458588;">(</spa= n><span style=3D"color: #458588;">test.found</span><span style=3D"color: #4= 58588;">)</span>, <span style=3D"color: #689d6a;">"type"</span><span style= =3D"color: #d79921;">)</span>; <span style=3D"color: #689d6a;">"found_types"</span> <span style=3D"color: #d79921;">slist</span> =3D> getvalues<span= style=3D"color: #d79921;">(</span> foundtype <span style=3D"color: #d79921= ;">)</span>; <span style=3D"color: #689d6a;">"founddir[$(test.found)]"</span> <span style=3D"color: #d79921;">string</span> =3D> <span style= =3D"color: #689d6a;">"$(foundtype[$(test.found)])"</span>, if =3D> strcmp<span style=3D"color: #d79921;">(</span> <span sty= le=3D"color: #689d6a;">"$(foundtype[$(test.found)])"</span>, <span style=3D= "color: #689d6a;">"directory"</span> <span style=3D"color: #d79921;">)</spa= n>; <span style=3D"color: #689d6a;">"found_dirs"</span> <span style=3D"color: #d79921;">slist</span> =3D> getindices<spa= n style=3D"color: #d79921;">(</span> founddir <span style=3D"color: #d79921= ;">)</span>; <span style=3D"color: #a89984; font-weight: bold;">classes</span>: <span style=3D"color: #689d6a;">"every_finding_has_trailing_slash"</s= pan> expression =3D> every<span style=3D"color: #d79921;">(</span> <s= pan style=3D"color: #689d6a;">".*\/$"</span>, @<span style=3D"color: #45858= 8;">(</span><span style=3D"color: #458588;">test.found</span><span style=3D= "color: #458588;">)</span> <span style=3D"color: #d79921;">)</span>; <span style=3D"color: #689d6a;">"every_finding_is_directory"</span> expression =3D> every<span style=3D"color: #d79921;">(</span> <s= pan style=3D"color: #689d6a;">"directory"</span>, @<span style=3D"color: #4= 58588;">(</span><span style=3D"color: #458588;">found_types</span><span sty= le=3D"color: #458588;">)</span> <span style=3D"color: #d79921;">)</span>; <span style=3D"color: #689d6a;">"every_found_directory_ends_trailing_= slash"</span> expression =3D> every<span style=3D"color: #d79921;">(</span> <s= pan style=3D"color: #689d6a;">".*\/$"</span>, @<span style=3D"color: #45858= 8;">(</span><span style=3D"color: #458588;">found_dirs</span><span style=3D= "color: #458588;">)</span> <span style=3D"color: #d79921;">)</span>; <span style=3D"color: #a89984; font-weight: bold;">reports</span>: <span style=3D"color: #689d6a;">"Every findfiles() result has trailin= g slash"</span> if =3D> <span style=3D"color: #689d6a;">"every_finding_has_trail= ing_slash"</span>; <span style=3D"color: #689d6a;">"Found: $(test.found)"</span>; <span style=3D"color: #689d6a;">"Every findfiles() result is a direct= ory"</span> if =3D> <span style=3D"color: #689d6a;">"every_finding_is_direct= ory"</span>; <span style=3D"color: #689d6a;">"Type $(test.found) =3D $(foundtype[$= (test.found)])"</span>; <span style=3D"color: #689d6a;">"Every directory returned by findfile= s() has trailing slash"</span> if =3D> <span style=3D"color: #689d6a;">"every_found_directory_e= nds_trailing_slash"</span>; <span style=3D"color: #689d6a;">}</span> </pre> </div> <pre class=3D"example" id=3D"org621c0a8"> # cf-agent -Kf ./t.cf --inform R: Every findfiles() result has trailing slash R: Found: /tmp/testdir/a/ R: Found: /tmp/testdir/b/ R: Found: /tmp/testdir/c/ R: Every findfiles() result is a directory R: Type /tmp/testdir/a/ =3D directory R: Type /tmp/testdir/b/ =3D directory R: Type /tmp/testdir/c/ =3D directory R: Every directory returned by findfiles() has trailing slash R: CFEngine: 3.21.8 </pre> <pre class=3D"example" id=3D"org118716e"> # cf-agent -KIf ./t.cf info: Created directory '/tmp/testdir/a/.', mode 0700 info: Created directory '/tmp/testdir/b/.', mode 0700 info: Created directory '/tmp/testdir/c/.', mode 0700 R: Found: /tmp/testdir/a R: Found: /tmp/testdir/b R: Found: /tmp/testdir/c R: Every findfiles() result is a directory R: Type /tmp/testdir/a =3D directory R: Type /tmp/testdir/b =3D directory R: Type /tmp/testdir/c =3D directory R: CFEngine: 3.24.0 </pre> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;help-cfengine" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">help-= [email protected]</a>.<br /> To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/= help-cfengine/877bud9pwl.fsf%40northern.tech?utm_medium=3Demail&utm_source= =3Dfooter">https://groups.google.com/d/msgid/help-cfengine/877bud9pwl.fsf%4= 0northern.tech</a>.<br /> --==-=-=-- --=-=-= Content-Type: text/plain; charset="UTF-8" -- Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/877bud9pwl.fsf%40northern.tech. --=-=-=--