xref: /illumos-gate/usr/src/cmd/auditd/plugin.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_PLUGIN_H
26 #define	_PLUGIN_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <security/auditd.h>
33 #include "queue.h"
34 
35 typedef struct thd {
36 	pthread_cond_t	thd_cv;
37 	pthread_mutex_t	thd_mutex;
38 	int		thd_waiting;
39 } thr_data_t;
40 
41 typedef struct plg plugin_t;
42 struct plg {
43 	boolean_t	plg_initialized;	/* if threads, pools created */
44 	boolean_t	plg_reopen;		/* call auditd_plugin_open */
45 	/*
46 	 * removed is 1 if last read of audit configuration didn't list this
47 	 * plugin or the plugin is marked as "inactive"; it needs to be removed.
48 	 */
49 	boolean_t	plg_removed;		/* plugin removed */
50 	boolean_t	plg_to_be_removed;	/* tentative removal state */
51 
52 	char		*plg_path;		/* plugin path */
53 	void		*plg_dlptr;		/* dynamic lib pointer */
54 	auditd_rc_t	(*plg_fplugin)(const char *, size_t, uint64_t, char **);
55 	auditd_rc_t	(*plg_fplugin_open)(const kva_t *, char **, char **);
56 	auditd_rc_t	(*plg_fplugin_close)(char **);
57 
58 	kva_t		*plg_kvlist;		/* plugin inputs */
59 	size_t		plg_qmax;		/* max queue size */
60 	size_t		plg_qmin;		/* min queue size */
61 
62 	uint64_t	plg_sequence;		/* buffer counter */
63 	uint64_t	plg_last_seq_out;	/* buffer counter (debug) */
64 	uint32_t	plg_tossed;		/* discards (debug) */
65 	uint32_t	plg_queued;		/* count buffers queued */
66 	uint32_t	plg_output;		/* count of buffers output */
67 	int		plg_priority;		/* current priority */
68 
69 	au_queue_t	plg_pool;		/* buffer pool */
70 	au_queue_t	plg_queue;		/* queue drawn from pool */
71 	int		plg_q_threshold;	/* max preallocated queue */
72 	audit_q_t	*plg_save_q_copy;	/* tmp holding for a record */
73 
74 	pthread_t	plg_tid;		/* thread id */
75 	pthread_cond_t	plg_cv;
76 	pthread_mutex_t	plg_mutex;
77 	int		plg_waiting;		/* output thread wait state */
78 
79 	int		plg_cnt;		/* continue policy */
80 
81 	int		plg_retry_time;		/* retry (seconds) */
82 
83 	plugin_t	*plg_next;		/* null is end of list */
84 };
85 
86 int	auditd_thread_init();
87 void	auditd_thread_close();
88 void	auditd_exit(int);
89 
90 extern plugin_t		*plugin_head;
91 extern pthread_mutex_t	plugin_mutex;
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif	/* _PLUGIN_H */
98