xref: /titanic_52/usr/src/lib/auditd_plugins/remote/audit_remote.h (revision 6a1af1a67532df169a657cce07140be64bdea084)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  */
26 
27 #ifndef	_AUDIT_REMOTE_H
28 #define	_AUDIT_REMOTE_H
29 
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <stdio.h>
36 #include <security/auditd.h>
37 
38 /* gettext() obfuscation routine for lint */
39 #ifdef __lint
40 #define	gettext(x)	x
41 #endif
42 
43 
44 /* send_record() return code */
45 enum send_record_rc {
46 	SEND_RECORD_SUCCESS,
47 	SEND_RECORD_NEXT,
48 	SEND_RECORD_RETRY,
49 	SEND_RECORD_FAIL
50 };
51 typedef enum send_record_rc send_record_rc_t;
52 
53 /* closing helpers - the reason of connection closure */
54 enum close_rsn_e {
55 		RSN_UNDEFINED,		/* reason not defined */
56 		RSN_INIT_POLL,		/* poll() initialization failed */
57 		RSN_TOK_RECV_FAILED,	/* token receiving failed */
58 		RSN_TOK_TOO_BIG,	/* unacceptable token size */
59 		RSN_TOK_UNVERIFIABLE,	/* received unverifiable token */
60 		RSN_SOCKET_CLOSE,	/* socket closure */
61 		RSN_SOCKET_CREATE,	/* socket creation */
62 		RSN_CONNECTION_CREATE,	/* connection creation */
63 		RSN_PROTOCOL_NEGOTIATE,	/* protocol version negotiation */
64 		RSN_GSS_CTX_ESTABLISH,	/* establish GSS-API context */
65 		RSN_GSS_CTX_EXP,	/* expiration of the GSS-API context */
66 		RSN_UNKNOWN_AF,		/* unknown address family */
67 		RSN_MEMORY_ALLOCATE,	/* memory allocation failure */
68 		RSN_OTHER_ERR		/* other, not classified error */
69 };
70 typedef enum close_rsn_e close_rsn_t;
71 
72 /* linked list of remote audit hosts (servers) */
73 typedef struct hostlist_s hostlist_t;
74 struct hostlist_s {
75 	hostlist_t	*next_host;
76 	struct hostent	*host;
77 	in_port_t	port;		/* TCP port number */
78 	gss_OID		mech;		/* GSS mechanism - see mech(4) */
79 };
80 
81 /* transq_t - single, already sent token in the transmit queue. */
82 struct transq_node_s {
83 	struct transq_node_s	*next;
84 	struct transq_node_s	*prev;
85 	gss_buffer_desc		seq_token;	/* seq num || plain token */
86 	uint64_t		seq_num;	/* seq number */
87 };
88 typedef struct transq_node_s transq_node_t;
89 
90 /* transq_hdr_t - the transmit queue header structure */
91 struct transq_hdr_s {
92 	struct transq_node_s	*head;
93 	struct transq_node_s	*end;
94 	long			count;	/* amount of nodes in the queue */
95 };
96 typedef struct transq_hdr_s transq_hdr_t;
97 
98 /* pipe_msg_s - the notification pipe message */
99 struct pipe_msg_s {
100 	int		sock_num;	/* socket fd to be poll()ed and more */
101 	boolean_t	sync;		/* call the sync routines */
102 };
103 typedef struct pipe_msg_s pipe_msg_t;
104 
105 
106 /*
107  * Cross audit_remote plugin source code shared functions and bool parameters.
108  *
109  * reset_transport() helpers:
110  *     arg1) DO_SYNC, DO_NOT_SYNC
111  *     arg2) DO_EXIT, DO_CLOSE, DO_NOT_EXIT, DO_NOT_CLOSE
112  */
113 #define	DO_SYNC		B_TRUE
114 #define	DO_NOT_SYNC	B_FALSE
115 #define	DO_EXIT		B_FALSE
116 #define	DO_CLOSE	B_TRUE
117 #define	DO_NOT_EXIT	B_CLOSE
118 #define	DO_NOT_CLOSE	B_EXIT
119 extern void		reset_transport(boolean_t, boolean_t);
120 extern send_record_rc_t send_record(struct hostlist_s *, const char *, size_t,
121     uint64_t, close_rsn_t *);
122 
123 #if DEBUG
124 #define	DPRINT(x) { (void) fprintf x; (void) fflush(dfile); }
125 #else
126 #define	DPRINT(x)
127 #endif
128 
129 #if DEBUG
130 extern FILE	*dfile;
131 #endif
132 
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif	/* _AUDIT_REMOTE_H */
139