Skip to content

Support reopening audit and debug logs#3521

Open
fremail wants to merge 3 commits intoowasp-modsecurity:v3/masterfrom
fremail:add/log-reopen
Open

Support reopening audit and debug logs#3521
fremail wants to merge 3 commits intoowasp-modsecurity:v3/masterfrom
fremail:add/log-reopen

Conversation

@fremail
Copy link

@fremail fremail commented Mar 23, 2026

This PR adds a new C API function msc_rules_reopen_logs() that allows connectors (Nginx, Apache, etc.) to reopen audit and debug log files without restarting. This is essential for log rotation — after logrotate renames the old file and creates a new one, the connector can call this function (e.g., on SIGUSR1 or SIGHUP) to start writing to the new file.

Inspired by changes in #2304
Resolves #1968
This change is required for resolving issue 121 in ModSecurity-nginx connector

@airween
Copy link
Member

airween commented Mar 23, 2026

Hi @fremail,

thanks for this PR - just for the record, there is (was) a similar PR previously, but for some reason it got stuck, see #2304.

But now, could you take a look at the Sonar issues? All of them generated by this PR.

If we merge this PR, then - I assume - we should add this new feature to the connector, right?

@fremail
Copy link
Author

fremail commented Mar 23, 2026

Hi @airween,

Yes, there was a similar PR. I was very disappointed that it stuck for years. I didn't find an option for committing into that PR, so I forked @brandonpayton's work and created this PR.

Fixing the Sonar issues.

If we merge this PR, then - I assume - we should add this new feature to the connector, right?

Right. Let's merge this PR first :)

@sonarqubecloud
Copy link

@fremail
Copy link
Author

fremail commented Mar 23, 2026

To be honest I don't know the best solution for the Sonar issues. Adding linter exceptions is not a fix actually. Adding platform specific code is also a weird solution. Both options cause extra Sonar issues 🤷‍♂️

Suggestions are welcome

@fremail
Copy link
Author

fremail commented Mar 24, 2026

@airween I've added a PR for the connector as well owasp-modsecurity/ModSecurity-nginx#372

I'm new to this stack and project, so please suggest preferred fixes/ways for the Sonar issues 🙏

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.

Add interface in libModSecurity for reopening log files

2 participants