bsm_event.c (185573) | bsm_event.c (186647) |
---|---|
1/*- 2 * Copyright (c) 2004 Apple Inc. 3 * Copyright (c) 2006 Robert N. M. Watson 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 * | 1/*- 2 * Copyright (c) 2004 Apple Inc. 3 * Copyright (c) 2006 Robert N. M. Watson 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 * |
30 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_event.c#16 $ | 30 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_event.c#17 $ |
31 */ 32 33#include <config/config.h> 34 35#include <bsm/libbsm.h> 36 37#include <string.h> | 31 */ 32 33#include <config/config.h> 34 35#include <bsm/libbsm.h> 36 37#include <string.h> |
38#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
38#include <pthread.h> | 39#include <pthread.h> |
40#endif |
|
39#include <stdio.h> 40#include <stdlib.h> 41 42#ifndef HAVE_STRLCPY 43#include <compat/strlcpy.h> 44#endif 45 46 47/* 48 * Parse the contents of the audit_event file to return 49 * au_event_ent entries 50 */ 51static FILE *fp = NULL; 52static char linestr[AU_LINE_MAX]; 53static const char *eventdelim = ":"; 54 | 41#include <stdio.h> 42#include <stdlib.h> 43 44#ifndef HAVE_STRLCPY 45#include <compat/strlcpy.h> 46#endif 47 48 49/* 50 * Parse the contents of the audit_event file to return 51 * au_event_ent entries 52 */ 53static FILE *fp = NULL; 54static char linestr[AU_LINE_MAX]; 55static const char *eventdelim = ":"; 56 |
57#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
55static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; | 58static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
59#endif |
|
56 57/* 58 * Parse one line from the audit_event file into the au_event_ent structure. 59 */ 60static struct au_event_ent * 61eventfromstr(char *str, struct au_event_ent *e) 62{ 63 char *evno, *evname, *evdesc, *evclass; --- 45 unchanged lines hidden (view full) --- 109 if (fp != NULL) 110 fseek(fp, 0, SEEK_SET); 111} 112 113void 114setauevent(void) 115{ 116 | 60 61/* 62 * Parse one line from the audit_event file into the au_event_ent structure. 63 */ 64static struct au_event_ent * 65eventfromstr(char *str, struct au_event_ent *e) 66{ 67 char *evno, *evname, *evdesc, *evclass; --- 45 unchanged lines hidden (view full) --- 113 if (fp != NULL) 114 fseek(fp, 0, SEEK_SET); 115} 116 117void 118setauevent(void) 119{ 120 |
121#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
117 pthread_mutex_lock(&mutex); | 122 pthread_mutex_lock(&mutex); |
123#endif |
|
118 setauevent_locked(); | 124 setauevent_locked(); |
125#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
119 pthread_mutex_unlock(&mutex); | 126 pthread_mutex_unlock(&mutex); |
127#endif |
|
120} 121 122/* 123 * Close the open file pointers. 124 */ 125void 126endauevent(void) 127{ 128 | 128} 129 130/* 131 * Close the open file pointers. 132 */ 133void 134endauevent(void) 135{ 136 |
137#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
129 pthread_mutex_lock(&mutex); | 138 pthread_mutex_lock(&mutex); |
139#endif |
|
130 if (fp != NULL) { 131 fclose(fp); 132 fp = NULL; 133 } | 140 if (fp != NULL) { 141 fclose(fp); 142 fp = NULL; 143 } |
144#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
134 pthread_mutex_unlock(&mutex); | 145 pthread_mutex_unlock(&mutex); |
146#endif |
|
135} 136 137/* 138 * Enumerate the au_event_ent entries. 139 */ 140static struct au_event_ent * 141getauevent_r_locked(struct au_event_ent *e) 142{ --- 23 unchanged lines hidden (view full) --- 166 return (e); 167} 168 169struct au_event_ent * 170getauevent_r(struct au_event_ent *e) 171{ 172 struct au_event_ent *ep; 173 | 147} 148 149/* 150 * Enumerate the au_event_ent entries. 151 */ 152static struct au_event_ent * 153getauevent_r_locked(struct au_event_ent *e) 154{ --- 23 unchanged lines hidden (view full) --- 178 return (e); 179} 180 181struct au_event_ent * 182getauevent_r(struct au_event_ent *e) 183{ 184 struct au_event_ent *ep; 185 |
186#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
174 pthread_mutex_lock(&mutex); | 187 pthread_mutex_lock(&mutex); |
188#endif |
|
175 ep = getauevent_r_locked(e); | 189 ep = getauevent_r_locked(e); |
190#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
176 pthread_mutex_unlock(&mutex); | 191 pthread_mutex_unlock(&mutex); |
192#endif |
|
177 return (ep); 178} 179 180struct au_event_ent * 181getauevent(void) 182{ 183 static char event_ent_name[AU_EVENT_NAME_MAX]; 184 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 40 unchanged lines hidden (view full) --- 225 return (NULL); 226} 227 228struct au_event_ent * 229getauevnam_r(struct au_event_ent *e, const char *name) 230{ 231 struct au_event_ent *ep; 232 | 193 return (ep); 194} 195 196struct au_event_ent * 197getauevent(void) 198{ 199 static char event_ent_name[AU_EVENT_NAME_MAX]; 200 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 40 unchanged lines hidden (view full) --- 241 return (NULL); 242} 243 244struct au_event_ent * 245getauevnam_r(struct au_event_ent *e, const char *name) 246{ 247 struct au_event_ent *ep; 248 |
249#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
233 pthread_mutex_lock(&mutex); | 250 pthread_mutex_lock(&mutex); |
251#endif |
|
234 ep = getauevnam_r_locked(e, name); | 252 ep = getauevnam_r_locked(e, name); |
253#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
235 pthread_mutex_unlock(&mutex); | 254 pthread_mutex_unlock(&mutex); |
255#endif |
|
236 return (ep); 237} 238 239struct au_event_ent * 240getauevnam(const char *name) 241{ 242 static char event_ent_name[AU_EVENT_NAME_MAX]; 243 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 35 unchanged lines hidden (view full) --- 279 return (NULL); 280} 281 282struct au_event_ent * 283getauevnum_r(struct au_event_ent *e, au_event_t event_number) 284{ 285 struct au_event_ent *ep; 286 | 256 return (ep); 257} 258 259struct au_event_ent * 260getauevnam(const char *name) 261{ 262 static char event_ent_name[AU_EVENT_NAME_MAX]; 263 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 35 unchanged lines hidden (view full) --- 299 return (NULL); 300} 301 302struct au_event_ent * 303getauevnum_r(struct au_event_ent *e, au_event_t event_number) 304{ 305 struct au_event_ent *ep; 306 |
307#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
287 pthread_mutex_lock(&mutex); | 308 pthread_mutex_lock(&mutex); |
309#endif |
|
288 ep = getauevnum_r_locked(e, event_number); | 310 ep = getauevnum_r_locked(e, event_number); |
311#ifdef HAVE_PTHREAD_MUTEX_LOCK |
|
289 pthread_mutex_unlock(&mutex); | 312 pthread_mutex_unlock(&mutex); |
313#endif |
|
290 return (ep); 291} 292 293struct au_event_ent * 294getauevnum(au_event_t event_number) 295{ 296 static char event_ent_name[AU_EVENT_NAME_MAX]; 297 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 42 unchanged lines hidden --- | 314 return (ep); 315} 316 317struct au_event_ent * 318getauevnum(au_event_t event_number) 319{ 320 static char event_ent_name[AU_EVENT_NAME_MAX]; 321 static char event_ent_desc[AU_EVENT_DESC_MAX]; --- 42 unchanged lines hidden --- |