-
Notifications
You must be signed in to change notification settings - Fork 200
CFE-4590, ENT-13239: Override default directory permissions #5931
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b959b5f
Added test for overriding default directory create mode
larsewi 59827e8
Skip remaining string comparisons after successful match
larsewi 928eb80
Added default_directory_create_mode to body agent control
larsewi 01e1a5a
Replaced hardcoded directory create mode with DEFAULTMODE
larsewi 3b554e8
Make sure the last configuration wins
larsewi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
tests/acceptance/10_files/agent_control_default_directory_create_mode.cf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| ############################################################################## | ||
| # | ||
| # Test overriding default directory create mode (CFE-4590, ENT-13239). | ||
| # | ||
| ############################################################################## | ||
|
|
||
|
|
||
| body common control | ||
| { | ||
| inputs => { "../default.cf.sub" }; | ||
| bundlesequence => { default("$(this.promise_filename)") }; | ||
| version => "1.0"; | ||
| } | ||
|
|
||
| body agent control { | ||
| # Override the default directory create mode to 0755 (it defaults to 0700 if | ||
| # not specified) | ||
| default_directory_create_mode => "0777"; # Make sure the last one wins | ||
| default_directory_create_mode => "a+rx"; # Can also use octets 0755 | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent init | ||
| { | ||
| methods: | ||
| "clean"; | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent test | ||
| { | ||
| meta: | ||
| "description" -> { "CFE-4590", "ENT-13239" } | ||
| string => "Test overriding default directory create mode"; | ||
|
|
||
| files: | ||
| "$(G.testdir)/foo/config.txt" | ||
| create => "true", | ||
| perms => m(0655); | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent check | ||
| { | ||
| vars: | ||
| "expected" | ||
| string => "[0-9]*755", | ||
| comment => "We only care about the last three octets (i.e., 755)"; | ||
| "actual" | ||
| string => filestat("$(G.testdir)/foo/", "modeoct"); | ||
|
|
||
| methods: | ||
| "Pass/FAIL" | ||
| usebundle => dcs_check_regcmp("$(expected)", "$(actual)", | ||
| "$(this.promise_filename)", "false"); | ||
|
|
||
| reports: | ||
| "Expected $(expected), actual $(actual)"; | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent clean | ||
| { | ||
| files: | ||
| "$(G.testdir)/foo/." | ||
| delete => tidy, | ||
| if => fileexist("$(this.promiser)"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? I don't understand the context or the reason for the change and what the change does.
I noticed around line 1141 there is another block that doesn't
continueI wonder if this whole block of code needs to be audited for correct logic?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are checking if the string matches any of the possible attributes. Once we find a match, we don't need to check if it matches the remaining attributes, because we know implicitly that they will not match.
There is no change in behavior, just less CPU cycles wasted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like i am just showing what i dont know about the code
but, @larsewi your description there made me wonder if this would be affected:
It's a silly example, but in some policies the same attribtue is set differently in different contexts and multiple contexts might apply.
I just wanted to be sure that not continuing to check for the attribute will not affect this (in the above simple example, expect the last one to win).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these
breaks will affect multiple configurations of the default directory create mode. However, I added a line in the policy to test this, just in case. I will merge once the acceptance test workflow from GitHub Actions have passed.