Skip to content

Commit

Permalink
Merge pull request #12029 from marcusburghardt/file_ownership_audit_c…
Browse files Browse the repository at this point in the history
…onfiguration_regex

Fix regex in file_ownership_audit_configuration
  • Loading branch information
jan-cerny authored May 31, 2024
2 parents 56d38b9 + 8797ca8 commit 50b89f8
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ template:
- /etc/audit/
- /etc/audit/rules.d/
file_regex:
- ^audit(\.rules|d\.conf)$
- ^.*audit(\.rules|d\.conf)$
- ^.*\.rules$
gid_or_name: '0'
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'
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ template:
- /etc/audit/
- /etc/audit/rules.d/
file_regex:
- .*audit\(\.rules\|d\.conf\)$
- .*\.rules$
- ^.*audit(\.rules|d\.conf)$
- ^.*\.rules$
allow_stricter_permissions: "true"
filemode: '0640'
2 changes: 1 addition & 1 deletion shared/templates/file_groupowner/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 ! -group {{{ GID_OR_NAME }}} -regex "{{{ FILE_REGEX[loop.index0] }}}"'
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -group {{{ GID_OR_NAME }}} -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_groupowner/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 ! -group {{{ GID_OR_NAME }}} -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chgrp {{{ GID_OR_NAME }}} {} \;
find {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -group {{{ GID_OR_NAME }}} -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chgrp {{{ GID_OR_NAME }}} {} \;
{{%- else %}}
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type d -exec chgrp {{{ GID_OR_NAME }}} {} \;
{{%- endif %}}
Expand Down
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
2 changes: 1 addition & 1 deletion shared/templates/file_permissions/ansible.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{%- if FILE_REGEX %}}
{{% set STATE="file" %}}
{{% set FIND_TYPE="-type f" %}}
{{% set FIND_FILE_REGEX="-regex \"" ~ FILE_REGEX[loop.index0] ~ "\"" %}}
{{% set FIND_FILE_REGEX="-regextype posix-extended -regex \"" ~ FILE_REGEX[loop.index0] ~ "\"" %}}
{{%- else %}}
{{% set STATE="directory" %}}
{{% set FIND_TYPE="-type d" %}}
Expand Down
2 changes: 1 addition & 1 deletion shared/templates/file_permissions/bash.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{% for path in FILEPATH %}}
{{%- if IS_DIRECTORY %}}
{{%- if FILE_REGEX %}}
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} {{{ PERMS }}} {{{ EXCLUDED_FILES_ARGS }}} -type f -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chmod {{{ FILEMODE }}} {} \;
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} {{{ PERMS }}} {{{ EXCLUDED_FILES_ARGS }}} -type f -regextype posix-extended -regex '{{{ FILE_REGEX[loop.index0] }}}' -exec chmod {{{ FILEMODE }}} {} \;
{{%- else %}}
find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} {{{ PERMS }}} -type d -exec chmod {{{ FILEMODE }}} {} \;
{{%- endif %}}
Expand Down

0 comments on commit 50b89f8

Please sign in to comment.