Overview
This article addresses a cron job failure that may occur after upgrading the maldet package. The issue prevents the system from properly rotating log files and generates automated error notifications.
Error Description
Administrators typically receive an email notification from the daily log rotation script containing the following message:
/etc/cron.daily/logrotate:
error: failed to rename /usr/local/maldetect/logs/inotify_log to /usr/local/maldetect/logs/inotify_log-20250225: Permission denied
Cause
This error occurs when the SELinux security contexts for the /usr/local/maldetect/logs/ directory are not correctly applied following a software upgrade. The logrotate process lacks the necessary permissions to rename and archive log files due to these misaligned security contexts.
Resolution Steps
To restore the correct SELinux context and resolve the permission error, execute the following commands with root privileges:
semanage fcontext -a -t var_log_t "/usr/local/maldetect/logs(/.*)?" > /dev/null 2>&1
restorecon -R -F /usr/local/maldetect/logs/ 2>/dev/null
Troubleshooting
If the error persists after applying the resolution steps, verify the following:
- Confirm that SELinux is enabled on the system by running getenforce.
- Ensure the /usr/local/maldetect/logs/ directory exists and has appropriate ownership before re-running the restoration command.
- Check for additional permission restrictions or custom security policies that may override standard SELinux contexts.