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