[PATCH 2/5] Store daemon config pointer in the periodic watcher's private data

Tyler Hicks tyhicks at canonical.com
Wed Aug 1 07:00:21 UTC 2012


In preparation for moving the periodic watcher to auditd-listen.c,
periodic_handler() cannot rely on having access to the config global
variable. That can be solved by using the private data pointer built
into libev watchers.
---
 src/auditd.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/auditd.c b/src/auditd.c
index a5b8b2c..e0ee702 100644
--- a/src/auditd.c
+++ b/src/auditd.c
@@ -445,7 +445,9 @@ static void netlink_handler(struct ev_loop *loop, struct ev_io *io,
 static void periodic_handler(struct ev_loop *loop, struct ev_periodic *per,
 			int revents )
 {
-	if (config.tcp_client_max_idle)
+	struct daemon_conf *config = (struct daemon_conf *) per->data;
+
+	if (config->tcp_client_max_idle)
 		auditd_tcp_listen_check_idle (loop);
 }
 
@@ -719,6 +721,7 @@ int main(int argc, char *argv[])
 
 	ev_periodic_init (&periodic_watcher, periodic_handler,
 			  0, config.tcp_client_max_idle, NULL);
+	periodic_watcher.data = &config;
 	if (config.tcp_client_max_idle)
 		ev_periodic_start (loop, &periodic_watcher);
 
-- 
1.7.9.5




More information about the Linux-audit mailing list