ansible-collection-hardening/tasks/suid_sgid.yml

25 lines
1 KiB
YAML
Raw Normal View History

2015-05-26 19:53:55 +00:00
---
2015-05-31 15:51:57 +00:00
- name: remove suid/sgid bit from binaries in blacklist
file: path='{{item}}' mode='a-s' state=file follow=yes
failed_when: false
2015-05-31 15:51:57 +00:00
with_items:
- '{{ os_security_suid_sgid_system_blacklist }}'
- '{{ os_security_suid_sgid_blacklist }}'
2015-05-26 19:53:55 +00:00
2015-05-31 15:51:57 +00:00
- name: find binaries with suid/sgid set
shell: find / -xdev \( -perm -4000 -o -perm -2000 \) -type f ! -path '/proc/*' -print 2>/dev/null
register: sbit_binaries
when: os_security_suid_sgid_remove_from_unknown
changed_when: False
2015-05-31 15:51:57 +00:00
- name: gather files from which to remove suids/sgids and remove system white-listed files
set_fact:
suid: '{{ sbit_binaries.stdout_lines | difference(os_security_suid_sgid_system_whitelist) }}'
when: os_security_suid_sgid_remove_from_unknown
2015-06-01 19:36:37 +00:00
- name: remove suid/sgid bit from all binaries except in system and user whitelist
file: path='{{item}}' mode='a-s' state=file follow=yes
2015-05-31 15:51:57 +00:00
with_items:
2017-06-06 14:39:13 +00:00
- '{{ suid | default() | difference(os_security_suid_sgid_whitelist) }}'
2015-06-01 21:46:05 +00:00
when: os_security_suid_sgid_remove_from_unknown