Skip to content

Conversation

@stevegrubb
Copy link
Contributor

Auplugin is intended to provide scaffolding most plugins need. It creates a worker thread, takes over main and places a lockless queue in between. This allows plugins to adhere to best practices with minimal effort.

This is still a work in progess, but is functional. Merging now to avoid future conflicts as work lands in master.

Reordered subdirectories so that audisp, auplugin, and audisp/plugins
build sequentially.

Created a reusable libqueue.la with its own install target and linked
it into libdisp.la along with libaucommon.la.

Linked libauplugin.la against libqueue.la and libaucommon.la

Integrated queue operations in auplugin.c with a local configuration object
Added a new manual page describing the auplugin initialization and
event processing functions, including their parameters and behavior.
Extend auplugin_event_feed() so the library can periodically perform
timer services itself. The worker thread would use sem_timedwait
(requires a new dequeue_timed() helper in audisp/queue.c) to wake
every timer_interval seconds. On timeout it would call
auparse_feed_age_events() and timer_cb(interval) if provided. This
keeps all auparse interactions in the worker thread, avoiding a third
thread and potential synchronization issues.
Updated the plugin feed loop to handle ETIMEDOUT after calling the
new helper
Replaced the hand-rolled event loop with calls to auplugin_init() and
auplugin_event_feed(), greatly simplifying main plugin logic. Modified
the SIGTERM handler to invoke auplugin_stop() for orderly shutdowns.
Updated the callback to retain the auparse_state_t pointer for metrics
reporting.
The filter plugin now initializes libauplugin and processes events
through auplugin_event_feed, simplifying the event loop and aging logic.
Rule loading is handled inside handle_event, reapplying expressions when
a SIGHUP is received. Signal handlers stop the libauplugin feed when
child processes exit or on SIGTERM. Build configuration adds the auplugin
include path and dependency so the new API is available during compilation.
Documented the new parameters for the feed API, clarifying how the timer
interval and callback interact. The default aging behavior is now
explained, including how a NULL callback still causes events to be flushed
after each timeout.
Included the auplugin header so the statsd plugin can initialize and
feed events through the common interface. Added a timer callback to
periodically gather and send metrics via auplugin_event_feed. Replaced
the manual polling loop in main with auplugin initialization and
event processing logic.
Added queue flag definitions and new helper prototypes in audisp/queue.h
for persistent queues and metrics retrieval.

Extended the queue implementation with disk persistence support and metric
functions in audisp/queue.c.

Introduced corresponding enums and API functions in auplugin.h including
stats callback registration.

Implemented the new initialization options and reporting helpers in
auplugin.c.

Documented usage of AUPLUGIN_Q_* flags and statistics helpers in auplugin.3
and auditd-plugins.5.
Added a new test audisp-test-queue to verify basic queue behavior,
persistence, and concurrency handling for the dispatcher queue
implementation.
Only honor the signal if it comes from the parent process so that other
tasks (cough, systemctl, cough) can't make the plugin exit without
the dispatcher in agreement. Otherwise it will restart the plugin.
Introduced a new API function queue_load_file in the dispatcher queue
headers for reading pending events from a persistence file

Implemented the loader in queue.c and integrated it into the
initialization path when Q_IN_FILE is used, restoring in-memory
state from disk

Updated the destruction logic to truncate the queue file once all
events have been processed before closing it
@stevegrubb stevegrubb merged commit 1083af6 into linux-audit:master Jun 28, 2025
4 checks passed
@stevegrubb stevegrubb deleted the auplugin branch June 28, 2025 01:46
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.

1 participant