xref: /titanic_41/usr/src/cmd/auditd/plugin.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58f775e0aSJan Friedel  * Common Development and Distribution License (the "License").
68f775e0aSJan Friedel  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*f8994074SJan Friedel  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef	_PLUGIN_H
267c478bd9Sstevel@tonic-gate #define	_PLUGIN_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifdef __cplusplus
297c478bd9Sstevel@tonic-gate extern "C" {
307c478bd9Sstevel@tonic-gate #endif
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <security/auditd.h>
337c478bd9Sstevel@tonic-gate #include "queue.h"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate typedef struct thd {
367c478bd9Sstevel@tonic-gate 	pthread_cond_t	thd_cv;
377c478bd9Sstevel@tonic-gate 	pthread_mutex_t	thd_mutex;
387c478bd9Sstevel@tonic-gate 	int		thd_waiting;
397c478bd9Sstevel@tonic-gate } thr_data_t;
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate typedef struct plg plugin_t;
427c478bd9Sstevel@tonic-gate struct plg {
437c478bd9Sstevel@tonic-gate 	boolean_t	plg_initialized;	/* if threads, pools created */
447c478bd9Sstevel@tonic-gate 	boolean_t	plg_reopen;		/* call auditd_plugin_open */
457c478bd9Sstevel@tonic-gate 	/*
46*f8994074SJan Friedel 	 * removed is 1 if last read of audit configuration didn't list this
47*f8994074SJan Friedel 	 * plugin or the plugin is marked as "inactive"; it needs to be removed.
487c478bd9Sstevel@tonic-gate 	 */
497c478bd9Sstevel@tonic-gate 	boolean_t	plg_removed;		/* plugin removed */
507c478bd9Sstevel@tonic-gate 	boolean_t	plg_to_be_removed;	/* tentative removal state */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 	char		*plg_path;		/* plugin path */
537c478bd9Sstevel@tonic-gate 	void		*plg_dlptr;		/* dynamic lib pointer */
548f775e0aSJan Friedel 	auditd_rc_t	(*plg_fplugin)(const char *, size_t, uint64_t, char **);
557c478bd9Sstevel@tonic-gate 	auditd_rc_t	(*plg_fplugin_open)(const kva_t *, char **, char **);
567c478bd9Sstevel@tonic-gate 	auditd_rc_t	(*plg_fplugin_close)(char **);
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 	kva_t		*plg_kvlist;		/* plugin inputs */
597c478bd9Sstevel@tonic-gate 	size_t		plg_qmax;		/* max queue size */
607c478bd9Sstevel@tonic-gate 	size_t		plg_qmin;		/* min queue size */
617c478bd9Sstevel@tonic-gate 
628f775e0aSJan Friedel 	uint64_t	plg_sequence;		/* buffer counter */
638f775e0aSJan Friedel 	uint64_t	plg_last_seq_out;	/* buffer counter (debug) */
647c478bd9Sstevel@tonic-gate 	uint32_t	plg_tossed;		/* discards (debug) */
657c478bd9Sstevel@tonic-gate 	uint32_t	plg_queued;		/* count buffers queued */
667c478bd9Sstevel@tonic-gate 	uint32_t	plg_output;		/* count of buffers output */
677c478bd9Sstevel@tonic-gate 	int		plg_priority;		/* current priority */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 	au_queue_t	plg_pool;		/* buffer pool */
707c478bd9Sstevel@tonic-gate 	au_queue_t	plg_queue;		/* queue drawn from pool */
717c478bd9Sstevel@tonic-gate 	int		plg_q_threshold;	/* max preallocated queue */
727c478bd9Sstevel@tonic-gate 	audit_q_t	*plg_save_q_copy;	/* tmp holding for a record */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	pthread_t	plg_tid;		/* thread id */
757c478bd9Sstevel@tonic-gate 	pthread_cond_t	plg_cv;
767c478bd9Sstevel@tonic-gate 	pthread_mutex_t	plg_mutex;
777c478bd9Sstevel@tonic-gate 	int		plg_waiting;		/* output thread wait state */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 	int		plg_cnt;		/* continue policy */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	int		plg_retry_time;		/* retry (seconds) */
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	plugin_t	*plg_next;		/* null is end of list */
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate int	auditd_thread_init();
877c478bd9Sstevel@tonic-gate void	auditd_thread_close();
887c478bd9Sstevel@tonic-gate void	auditd_exit(int);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate extern plugin_t		*plugin_head;
917c478bd9Sstevel@tonic-gate extern pthread_mutex_t	plugin_mutex;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #ifdef __cplusplus
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate #endif
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #endif	/* _PLUGIN_H */
98