Skip to content

Commit

Permalink
Specify regextype for find command
Browse files Browse the repository at this point in the history
Using escaping resolved the issue with find but created an issue with
OVAL. Therefore, the escaping was removed to preserve the OVAL behavior
and the file_onwer template was updated to specify a more robust regex
type for find command.
  • Loading branch information
marcusburghardt committed May 29, 2024
1 parent b499a69 commit b9432e0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ template:
- /etc/audit/
- /etc/audit/rules.d/
file_regex:
- ^.*/audit\(\.rules\|d\.conf\)$
- ^.*audit(\.rules|d\.conf)$
- ^.*\.rules$
fileuid: '0'
2 changes: 1 addition & 1 deletion shared/templates/file_owner/ansible.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{%- endif %}}

- name: Find {{{ path }}} file(s) matching {{{ FILE_REGEX[loop.index0] }}}{{% if RECURSIVE %}} recursively{{% endif %}}
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regex "{{{ FILE_REGEX[loop.index0] }}}"'
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regextype posix-extended -regex "{{{ FILE_REGEX[loop.index0] }}}"'
register: files_found
changed_when: False
failed_when: False
Expand Down
2 changes: 1 addition & 1 deletion shared/templates/file_owner/bash.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{%- if IS_DIRECTORY %}}
{{%- if FILE_REGEX %}}

find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown {{{ FILEUID }}} {} \;
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -uid {{{ FILEUID }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chown {{{ FILEUID }}} {} \;
{{%- else %}}
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chown {{{ FILEUID }}} {} \;
{{%- endif %}}
Expand Down

0 comments on commit b9432e0

Please sign in to comment.