Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENT-11959: Fixed modules_presence bundle for Windows agents #2923

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

craigcomstock
Copy link
Contributor

With findfiles returning proper back-slashed paths this policy was broken due to _vendored_dir and _override_dir being used with mixed slashed path and used as a replacement string.

Ticket: ENT-11959
Changelog: none

@craigcomstock craigcomstock marked this pull request as draft July 9, 2024 19:52
Copy link
Member

@nickanderson nickanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look dangerous. Though I don't fully understand the reasoning.

windows::
"_package_paths_tmp" slist => findfiles("\Q$(_override_dir)\E*");
"_package_paths_tmp" slist => findfiles("$(_override_dir)*");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the treatment as literal string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, because this.promise_dirname on windows contains backslashes. SO this change switches to using only backslashes on windows. but what were we protecting against with \Q \E?. findfiles() is glob, but \Q\E is pcre right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because findfiles doesn't work with those in there.

If I leave these out I get

R: _override_dir: C:\Program Files\Cfengine\inputs\cfe_internal\update\..\..\modules\packages\
R: _package_paths_tmp: [
  "C:\\Program Files\\Cfengine\\inputs\\cfe_internal\\update\\..\\..\\modules\\packages\\craig.mustache",
  "C:\\Program Files\\Cfengine\\inputs\\cfe_internal\\update\\..\\..\\modules\\packages\\vendored"
]

If I leave them in I get

R: _override_dir: C:\Program Files\Cfengine\inputs\cfe_internal\update\..\..\modules\packages\
R: _package_paths_tmp: []

I guess that new findfiles() handles windows paths with back-slashes in a different way which "just works" now?

Maybe because it uses true/fixed globbing where before it used PCRE?

@larsewi would know for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notice the acceptance tests for findfiles on windows...

https://github.com/cfengine/core/blob/305ea57c670a49ec6e8025c89359e9cc093d4e93/tests/acceptance/01_vars/02_functions/findfiles.cf#L87-L96

All back-slashes

    windows::
      "expected[a]" string => "$(G.testdir)\\a,$(G.testdir)\\d,$(G.testdir)\\g";
      "expected[b]" string => "$(G.testdir)\\a,$(G.testdir)\\bc,$(G.testdir)\\d,$(G.testdir)\\g,$(G.testdir)\\klm";

      "expected[c]" string => "$(G.testdir)\\d\\e,$(G.testdir)\\g\\h";
      "expected[d]" string => "$(G.testdir)\\a,$(G.testdir)\\bc";
      "expected[e]" string => "";

      "expected[g]" string => "$(G.testdir)\\a,$(G.testdir)\\bc,$(G.testdir)\\d,$(G.testdir)\\g,$(G.testdir)\\klm,$(G.testdir)\\d\\e,$(G.testdir)\\g\\h,$(G.testdir)\\klm\\nop,$(G.testdir)\\d\\e\\f,$(G.testdir)\\g\\h\\i,$(G.testdir)\\klm\\nop\\qrs,$(G.testdir)\\g\\h\\i\\j";
      "expected[h]" string => "$(G.testdir)\\g\\h\\i\\j";

With findfiles returning proper back-slashed paths this policy was broken due to _vendored_dir and _override_dir being used with mixed slashed path and used as a replacement string.

Ticket: ENT-11959
Changelog: none
@@ -860,6 +861,8 @@ bundle agent modules_presence

reports:
DEBUG::
"_override_dir: $(_override_dir)";
"_package_paths_tmp: $(with)" with => storejson(_package_paths_tmp);
Copy link
Contributor Author

@craigcomstock craigcomstock Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added _override_dir and _package_paths_tmp for debugging on windows.

@craigcomstock craigcomstock marked this pull request as ready for review July 9, 2024 20:35
@craigcomstock craigcomstock merged commit b97b593 into cfengine:master Jul 10, 2024
4 checks passed
@craigcomstock craigcomstock deleted the ENT-11959/master branch July 10, 2024 12:55
@craigcomstock
Copy link
Contributor Author

no cherry pick can be made, 3.21.x operates differently with globs and windows. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants