xref: /titanic_44/usr/src/cmd/auditd/plugin.h (revision bb5c894bdad0d78b8fec5d050bda354c84f7c054)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  */
26 
27 #ifndef	_PLUGIN_H
28 #define	_PLUGIN_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <security/auditd.h>
35 #include "queue.h"
36 
37 typedef struct thd {
38 	pthread_cond_t	thd_cv;
39 	pthread_mutex_t	thd_mutex;
40 	int		thd_waiting;
41 } thr_data_t;
42 
43 typedef struct plg plugin_t;
44 struct plg {
45 	boolean_t	plg_initialized;	/* if threads, pools created */
46 	boolean_t	plg_reopen;		/* call auditd_plugin_open */
47 	/*
48 	 * removed is 1 if last read of audit_control didn't list this
49 	 * plugin; it needs to be removed.
50 	 */
51 	boolean_t	plg_removed;		/* plugin removed */
52 	boolean_t	plg_to_be_removed;	/* tentative removal state */
53 
54 	char		*plg_path;		/* plugin path */
55 	void		*plg_dlptr;		/* dynamic lib pointer */
56 	auditd_rc_t	(*plg_fplugin)(const char *, size_t, uint64_t, char **);
57 	auditd_rc_t	(*plg_fplugin_open)(const kva_t *, char **, char **);
58 	auditd_rc_t	(*plg_fplugin_close)(char **);
59 
60 	kva_t		*plg_kvlist;		/* plugin inputs */
61 	size_t		plg_qmax;		/* max queue size */
62 	size_t		plg_qmin;		/* min queue size */
63 
64 	uint64_t	plg_sequence;		/* buffer counter */
65 	uint64_t	plg_last_seq_out;	/* buffer counter (debug) */
66 	uint32_t	plg_tossed;		/* discards (debug) */
67 	uint32_t	plg_queued;		/* count buffers queued */
68 	uint32_t	plg_output;		/* count of buffers output */
69 	int		plg_priority;		/* current priority */
70 
71 	au_queue_t	plg_pool;		/* buffer pool */
72 	au_queue_t	plg_queue;		/* queue drawn from pool */
73 	int		plg_q_threshold;	/* max preallocated queue */
74 	audit_q_t	*plg_save_q_copy;	/* tmp holding for a record */
75 
76 	pthread_t	plg_tid;		/* thread id */
77 	pthread_cond_t	plg_cv;
78 	pthread_mutex_t	plg_mutex;
79 	int		plg_waiting;		/* output thread wait state */
80 
81 	int		plg_cnt;		/* continue policy */
82 
83 	int		plg_retry_time;		/* retry (seconds) */
84 
85 	plugin_t	*plg_next;		/* null is end of list */
86 };
87 
88 int	auditd_thread_init();
89 void	auditd_thread_close();
90 void	auditd_exit(int);
91 
92 extern plugin_t		*plugin_head;
93 extern pthread_mutex_t	plugin_mutex;
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif	/* _PLUGIN_H */
100