summaryrefslogtreecommitdiffstats
path: root/seaudit/seaudit.h
blob: 34be02b186c8b41bcdd4dd0f7e59fc79ca123c0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/**
 *  @file
 *  Declaration of the main driver class for seaudit.
 *
 *  @author Jeremy A. Mowery jmowery@tresys.com
 *  @author Jason Tang jtang@tresys.com
 *  @author Jeremy Solt jsolt@tresys.com
 *
 *  Copyright (C) 2003-2007 Tresys Technology, LLC
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef SEAUDIT_H
#define SEAUDIT_H

#include "preferences.h"
#include <apol/policy.h>
#include <apol/policy-path.h>
#include <seaudit/log.h>
#include <stdio.h>
#include <time.h>

typedef struct seaudit seaudit_t;

#define COPYRIGHT_INFO "Copyright (c) 2003-2007 Tresys Technology, LLC"

/**
 * Retrieve the preferences object associated with the seaudit object.
 *
 * @param s seaudit object to query.
 *
 * @return Pointer to a preferences object.  Do not free() this pointer.
 */
preferences_t *seaudit_get_prefs(seaudit_t * s);

/**
 * Set the currently loaded policy for seaudit.  This will also update
 * the preferences object's recently loaded policies.
 *
 * @param s seaudit object to modify.
 * @param policy New policy file for seaudit.  If NULL then seaudit
 * has no policy opened.  Afterwards seaudit takes ownership of the
 * policy.
 * @param path If policy is not NULL, then add this path to the most
 * recently used policy files.  This function takes ownership of the
 * path.
 */
void seaudit_set_policy(seaudit_t * s, apol_policy_t * policy, apol_policy_path_t * path);

/**
 * Retrieve the currently loaded policy.
 *
 * @param s seaudit object to query.
 *
 * @return Pointer to an apol policy, or NULL if none loaded.  Treat
 * this as a const pointer.
 */
apol_policy_t *seaudit_get_policy(seaudit_t * s);

/**
 * Return the path to the currently loaded policy.  If the current
 * policy is modular then this returns the base policy's path.
 *
 * @param s seaudit object to query.
 *
 * @return Path of policy, or NULL if none loaded.  Treat this as a
 * const pointer.
 */
apol_policy_path_t *seaudit_get_policy_path(seaudit_t * s);

/**
 * Set the currently loaded log for seaudit.  This will also update
 * the preferences object's recently loaded files.
 *
 * @param s seaudit object to modify.
 * @param log New log file for seaudit.  If NULL then seaudit has no
 * log files opened.  Afterwards seaudit takes ownership of the log.
 * @param f File handler that was used to open the log.  Afterwards
 * seaudit takes ownership of this handler.
 * @param filename If log is not NULL, then add this filename to the
 * most recently used files.
 */
void seaudit_set_log(seaudit_t * s, seaudit_log_t * log, FILE * f, const char *filename);

/**
 * Command seaudit to (re)parse its log file.
 *
 * @param s seaudit object containing the log.
 *
 * @return 0 if log parsed cleanly, < 0 upon errors, or > 0 if there
 * were warnings.
 */
int seaudit_parse_log(seaudit_t * s);

/**
 * Retrieve the currently loaded log file.
 *
 * @param s seaudit object to query.
 *
 * @return Pointer to a libseaudit log, or NULL if none loaded.  Treat
 * this as a const pointer.
 */
seaudit_log_t *seaudit_get_log(seaudit_t * s);

/**
 * Return the path to the currently loaded log file.
 *
 * @param s seaudit object to query.
 *
 * @return Path of log file, or NULL if none loaded.  Treat this as a
 * const pointer.
 */
char *seaudit_get_log_path(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all users found within
 * currently opened log files.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted users, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_users(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all roles found within
 * currently opened log files.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted roles, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_roles(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all types found within
 * currently opened log files.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_types(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all mls levels 
 * found within currently opened log files.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_mls_lvl(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all mls clearance 
 * found within currently opened log files.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted types, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_mls_clr(seaudit_t * s);

/**
 * Return a vector of strings corresponding to all object classes
 * found within currently opened log file.  The vector will be sorted
 * alphabetically.
 *
 * @param s seaudit object to query.
 *
 * @return Vector of sorted classes, or NULL if no log is loaded.  The
 * caller must call apol_vector_destroy() upon the return value.
 */
apol_vector_t *seaudit_get_log_classes(seaudit_t * s);

/**
 * Return the number of messages in the current log.
 *
 * @param s seaudit object to query.
 *
 * @return Number of log messages, or 0 if no log is opened.
 */
size_t seaudit_get_num_log_messages(seaudit_t * s);

/**
 * Return the time stamp for the first message in the currently opened
 * log.
 *
 * @param s seaudit object to query.
 *
 * @return Time of the first log message, or NULL if no log is opened.
 * Treat this as a const pointer.
 */
const struct tm *seaudit_get_log_first(seaudit_t * s);

/**
 * Return the time stamp for the last message in the currently opened
 * log.
 *
 * @param s seaudit object to query.
 *
 * @return Time of the last log message, or NULL if no log is opened.
 * Treat this as a const pointer.
 */
const struct tm *seaudit_get_log_last(seaudit_t * s);

#endif