---
title: Verify Group Who Owns the rsyslog Drop-In Directory
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Verify Group Who Owns the rsyslog
  Drop-In Directory
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Verify Group Who Owns the rsyslog Drop-In Directory
 
## Description{% #description %}

The `/etc/rsyslog.d` directory should be group-owned by `root`.

## Rationale{% #rationale %}

A user who can write to the drop-in directory can add a configuration file that rsyslog loads at its next start.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

The following script can be run on the host to remediate the issue.

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-core && rpm --quiet -q rsyslog; then

newgroup=""
if getent group "0" >/dev/null 2>&1; then
  newgroup="0"
fi

if [[ -z "${newgroup}" ]]; then
  >&2 echo "0 is not a defined group on the system"
else
find -P /etc/rsyslog.d/ -maxdepth 0 -type d  ! -group 0 -exec chgrp --no-dereference "$newgroup" {} \;

fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```

### Ansible playbook{% #ansible-playbook %}

The following playbook can be run with Ansible to remediate the issue.

```gdscript3
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - CCE-87845-4
  - configure_strategy
  - directory_groupowner_etc_rsyslog_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Set the directory_groupowner_etc_rsyslog_d_newgroup variable if represented
    by gid
  ansible.builtin.set_fact:
    directory_groupowner_etc_rsyslog_d_newgroup: '0'
  when:
  - '"kernel-core" in ansible_facts.packages'
  - '"rsyslog" in ansible_facts.packages'
  tags:
  - CCE-87845-4
  - configure_strategy
  - directory_groupowner_etc_rsyslog_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Ensure group owner on /etc/rsyslog.d/
  ansible.builtin.file:
    path: /etc/rsyslog.d/
    follow: false
    state: directory
    group: '{{ directory_groupowner_etc_rsyslog_d_newgroup }}'
  when:
  - '"kernel-core" in ansible_facts.packages'
  - '"rsyslog" in ansible_facts.packages'
  tags:
  - CCE-87845-4
  - configure_strategy
  - directory_groupowner_etc_rsyslog_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
```
