diff options
Diffstat (limited to 'contrib/openbsm/libbsm/bsm_audit.c')
-rw-r--r-- | contrib/openbsm/libbsm/bsm_audit.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/contrib/openbsm/libbsm/bsm_audit.c b/contrib/openbsm/libbsm/bsm_audit.c index 2fd9466..3510639 100644 --- a/contrib/openbsm/libbsm/bsm_audit.c +++ b/contrib/openbsm/libbsm/bsm_audit.c @@ -30,7 +30,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#31 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#34 $ */ #include <sys/types.h> @@ -48,7 +48,9 @@ #include <netinet/in.h> #include <errno.h> +#ifdef HAVE_PTHREAD_MUTEX_LOCK #include <pthread.h> +#endif #include <stdlib.h> #include <string.h> @@ -65,7 +67,9 @@ static int audit_rec_count = 0; */ static LIST_HEAD(, au_record) audit_free_q; +#ifdef HAVE_PTHREAD_MUTEX_LOCK static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +#endif /* * This call frees a token_t and its internal data. @@ -93,7 +97,9 @@ au_open(void) { au_record_t *rec = NULL; +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_lock(&mutex); +#endif if (audit_rec_count == 0) LIST_INIT(&audit_free_q); @@ -108,7 +114,9 @@ au_open(void) LIST_REMOVE(rec, au_rec_q); } +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_unlock(&mutex); +#endif if (rec == NULL) { /* @@ -125,10 +133,14 @@ au_open(void) return (-1); } +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_lock(&mutex); +#endif if (audit_rec_count == MAX_AUDIT_RECORDS) { +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_unlock(&mutex); +#endif free(rec->data); free(rec); @@ -140,7 +152,9 @@ au_open(void) open_desc_table[audit_rec_count] = rec; audit_rec_count++; +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_unlock(&mutex); +#endif } @@ -221,7 +235,7 @@ au_assemble(au_record_t *rec, short event) aia.ai_termid.at_type = AU_IPv4; aia.ai_termid.at_addr[0] = INADDR_ANY; if (auditon(A_GETKAUDIT, &aia, sizeof(aia)) < 0) { - if (errno != ENOSYS) + if (errno != ENOSYS && errno != EPERM) return (-1); #endif /* HAVE_AUDIT_SYSCALLS */ tot_rec_size = rec->len + AUDIT_HEADER_SIZE + @@ -242,6 +256,8 @@ au_assemble(au_record_t *rec, short event) (IN6_IS_ADDR_UNSPECIFIED(aptr)) ? AUDIT_HEADER_SIZE : AUDIT_HEADER_EX_SIZE(&aia); break; + default: + return (-1); } tot_rec_size = rec->len + hdrsize + AUDIT_TRAILER_SIZE; /* @@ -299,12 +315,16 @@ au_teardown(au_record_t *rec) rec->used = 0; rec->len = 0; +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_lock(&mutex); +#endif /* Add the record to the freelist tail */ LIST_INSERT_HEAD(&audit_free_q, rec, au_rec_q); +#ifdef HAVE_PTHREAD_MUTEX_LOCK pthread_mutex_unlock(&mutex); +#endif } #ifdef HAVE_AUDIT_SYSCALLS |