Skip to content

Conversation

@akuzminsky
Copy link
Member

@akuzminsky akuzminsky commented Dec 26, 2025

Summary

  • Disables auditd's built-in log rotation in development environment
  • Moves rotation responsibility to logrotate with size-based trigger (50MB)
  • Ensures postrotate hook runs to restore ACLs for CloudWatch agent

Problem

CloudWatch agent was losing access to /var/log/audit/audit.log after rotation.
Auditd was rotating logs internally (every 50MB), which bypassed logrotate's
postrotate hook that restores ACLs. The fix in #215 only worked for logrotate-
triggered rotations, not auditd's own rotations.

Test plan

After the pr is merged:

  • Deploy to development jumphost
  • Verify auditd.conf has max_log_file_action = ignore
  • Verify logrotate config has size 50M
  • Wait for rotation (or force with logrotate -f /etc/logrotate.d/audit)
  • Confirm CloudWatch agent maintains access after rotation

Auditd's built-in rotation was causing CloudWatch agent to lose read
access to audit logs. When auditd rotates at 50MB, it bypasses
logrotate's postrotate hook that restores ACLs for the cwagent user.

Changes (development environment only):
- Disable auditd rotation: max_log_file_action = ignore
- Switch logrotate to size-based rotation (50M) matching auditd threshold
- Keep 10 rotated logs with compression

This ensures the postrotate ACL restore hook runs on every rotation.
Testing in development before rolling out to sandbox/production.
@akuzminsky akuzminsky merged commit 87d2e17 into main Dec 26, 2025
2 checks passed
@akuzminsky akuzminsky deleted the fix-audit-log-rotation-acl-dev branch December 26, 2025 15:42
akuzminsky added a commit that referenced this pull request Dec 26, 2025
The ACL-based approach from #215/#219 failed because auditd ignores
default ACLs when creating files. When auditd recreates the log file
after rotation, it sets permissions to 0600 with no ACLs, blocking
CloudWatch agent access.

Solution: Use standard Unix group permissions instead of ACLs.
- Set auditd log_group to 'adm' (cwagent is already in adm group)
- Logrotate creates files with group 'adm'
- Remove ACL scripts and related resources

This is simpler and more reliable than ACLs since auditd respects
log_group when creating files.

Testing in development before rolling out to other environments.
akuzminsky added a commit that referenced this pull request Dec 26, 2025
The ACL-based approach from #215/#219 failed because auditd ignores
default ACLs when creating files. When auditd recreates the log file
after rotation, it sets permissions to 0600 with no ACLs, blocking
CloudWatch agent access.

Solution: Use standard Unix group permissions instead of ACLs.
- Set auditd log_group to 'adm' (cwagent is already in adm group)
- Logrotate creates files with group 'adm'
- Remove ACL scripts and related resources

This is simpler and more reliable than ACLs since auditd respects
log_group when creating files.

Testing in development before rolling out to other environments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants