Execution
Date
08 Dec 2025 13:40:18 +0000
Duration
00:10:06.79
Controller
aio1.openstack.local
User
root
Versions
Ansible
2.18.6
ara
1.7.4 / 1.7.4
Python
3.12.11
Summary
15
Hosts
608
Tasks
2412
Results
18
Plays
158
Files
0
Records
File: /home/zuul/src/opendev.org/openstack/ansible-hardening/tasks/rhel7stig/file_perms.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | --- # Copyright 2016, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - name: V-71849 - Get packages with incorrect file permissions or ownership ansible.builtin.shell: "grep '^.M' {{ temp_dir }}/rpmverify.txt | awk '{ print $NF }'" register: rpmverify_package_list changed_when: false when: - not check_mode | bool - ansible_facts['pkg_mgr'] == 'dnf' - security_reset_perm_ownership | bool tags: - file_perms - high - V-71849 - name: V-71849 - Reset file permissions/ownership to vendor values shell: "rpm {{ item[0] }} `rpm -qf {{ item[1] }}`" # noqa: command-instead-of-shell command-instead-of-module risky-shell-pipe changed_when: false with_nested: - ["--setperms", "--setugids"] - "{{ rpmverify_package_list.stdout_lines | default([]) }}" when: - not check_mode | bool - ansible_facts['pkg_mgr'] == 'dnf' - rpmverify_package_list is defined - rpmverify_package_list.stdout_lines | length > 0 async: 300 poll: 0 tags: - file_perms - high - V-71849 # don't trigger ANSIBLE0013 - skip_ansible_lint - name: Search for files/directories with an invalid owner ansible.builtin.command: find / -xdev -nouser -fstype local register: invalid_owner_files changed_when: false when: - security_search_for_invalid_owner | bool tags: - always - name: V-72007 - All files and directories must have a valid owner. ansible.builtin.debug: msg: | Files and directories were found that are owned by an invalid user: {{ invalid_owner_files.stdout_lines | join('\n') }} when: - invalid_owner_files is defined - invalid_owner_files.stdout_lines is defined - invalid_owner_files.stdout_lines | length > 0 tags: - file_perms - medium - V-72007 - name: Search for files/directories with an invalid group owner ansible.builtin.command: find / -xdev -nogroup -fstype local register: invalid_group_owner_files changed_when: false when: - security_search_for_invalid_group_owner | bool tags: - always - name: V-72009 - All files and directories must have a valid group owner. ansible.builtin.debug: msg: | Files and directories were found that are owned by an invalid group: {{ invalid_group_owner_files.stdout_lines | join('\n') }} when: - invalid_group_owner_files is defined - invalid_group_owner_files.stdout_lines is defined - invalid_group_owner_files.stdout_lines | length > 0 tags: - file_perms - medium - V-72009 - name: Set proper owner, group owner, and permissions on home directories ansible.builtin.file: dest: "{{ item.dir }}" owner: "{{ item.name }}" group: "{{ item.group.name }}" mode: "g-ws,o-rwxt" when: - item.uid >= 1000 - item.name != 'nobody' - security_set_home_directory_permissions_and_owners | bool with_items: "{{ hardening_user_list.users | selectattr('uid', 'greaterthan', 999) | list }}" tags: - medium - file_perms - V-72017 - V-72019 - V-72021 - name: Find all world-writable directories ansible.builtin.shell: "find / -perm -002 -type d -exec ls -lLd {} \\; | tr -s ' ' | cut -d' ' -f 4,9 | grep -v ^root" register: world_writable_dirs changed_when: false failed_when: false check_mode: false when: - security_find_world_writable_dirs | bool tags: - always - name: V-72047 - All world-writable directories must be group-owned by root, sys, bin, or an application group. ansible.builtin.debug: msg: | The group owners on the following world-writable directories should be examined: {{ world_writable_dirs.stdout }} when: - world_writable_dirs is defined - world_writable_dirs is not skipped tags: - medium - file_perms - V-72047 - name: Check if /etc/cron.allow exists ansible.builtin.stat: path: /etc/cron.allow register: cron_allow_check tags: - always - name: Set owner/group owner on /etc/cron.allow ansible.builtin.file: path: /etc/cron.allow owner: root group: root when: - cron_allow_check is defined - cron_allow_check.stat.exists tags: - medium - file_perms - V-72053 - V-72055 |