Skip to content

Commit ef28e7d

Browse files
author
Conor Schaefer
committed
Supports minimizing access on symlinked system dirs
Uses a two-pass approach that inspects all target directories, then only operates on the true "directories," skipping the symlinks, if any. Using the "recurse=true" parameter ensures that the suid/sgid modifications are applied to files as well as directories.
1 parent 5216326 commit ef28e7d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tasks/minimize_access.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
---
2-
- name: minimize access
3-
file: path='{{item}}' mode='go-w' recurse=yes
2+
# Using a two-pass approach for checking directories in order to support symlinks.
3+
- name: find directories for minimizing access
4+
stat:
5+
path: "{{ item }}"
6+
register: minimize_access_directories
47
with_items:
58
- '/usr/local/sbin'
69
- '/usr/local/bin'
710
- '/usr/sbin'
8-
- '/usr/bin'
11+
- '/usr/bin'
912
- '/sbin'
1013
- '/bin'
1114
- '{{os_env_extra_user_paths}}'
1215

16+
- name: minimize access
17+
file: path='{{item.stat.path}}' mode='go-w' recurse=yes
18+
when: item.stat.isdir
19+
with_items: "{{ minimize_access_directories.results }}"
20+
1321
- name: change shadow ownership to root and mode to 0600 | DTAG SEC Req 3.21-7
1422
file: dest='/etc/shadow' owner={{ os_shadow_perms.owner }} group={{ os_shadow_perms.group }} mode={{ os_shadow_perms.mode }}
1523

0 commit comments

Comments
 (0)