Verify User Who Owns /etc/sysctl.d Directory
An XCCDF Rule
Description
To properly set the owner of/etc/sysctl.d
, run the command: $ sudo chown root /etc/sysctl.d
Rationale
The ownership of the /etc/sysctl.d directory by the root user is important because this directory hosts kernel configuration. Protection of this directory is critical for system security. Assigning the ownership to root ensures exclusive control of the kernel configuration.
- ID
- xccdf_org.ssgproject.content_rule_directory_owner_etc_sysctld
- Severity
- Medium
- References
- Updated
Remediation Templates
An Ansible Snippet
- name: Gather the package facts
package_facts:
manager: auto
tags:
- configure_strategy
- directory_owner_etc_sysctld
A Shell Script
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
find -H /etc/sysctl.d/ -maxdepth 1 -type d -exec chown -L 0 {} \;
else
>&2 echo 'Remediation is not applicable, nothing was done'
fi