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

feat(os_hardening): extend file permission tasks to cover more files #489

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions roles/os_hardening/tasks/minimize_access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,43 @@
- "{{ minimize_access_directories.results }}"
- stdout_lines

- name: Find shadow files
stat:
path: "{{ item }}"
loop:
- '/etc/shadow'
- '/etc/gshadow'
- '/etc/shadow-'
- '/etc/gshadow-'
register: minimize_access_shadow_files

- name: Change shadow ownership to root and mode to 0600 | os-02
file:
dest: '/etc/shadow'
dest: "{{ item.item }}"
owner: '{{ os_shadow_perms.owner }}'
group: '{{ os_shadow_perms.group }}'
mode: '{{ os_shadow_perms.mode }}'
when: item.stat.exists
loop: "{{ minimize_access_shadow_files.results }}"

- name: Find passwd files
stat:
path: "{{ item }}"
loop:
- '/etc/passwd'
- '/etc/group'
- '/etc/passwd-'
- '/etc/group-'
register: minimize_access_passwd_files

- name: Change passwd ownership to root and mode to 0644 | os-03
file:
dest: '/etc/passwd'
dest: "{{ item.item }}"
owner: '{{ os_passwd_perms.owner }}'
group: '{{ os_passwd_perms.group }}'
mode: '{{ os_passwd_perms.mode }}'
when: item.stat.exists
loop: "{{ minimize_access_passwd_files.results }}"

- name: Change su-binary to only be accessible to user and group root
file:
Expand Down