17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*8f775e0aSJan Friedel * Common Development and Distribution License (the "License"). 6*8f775e0aSJan Friedel * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*8f775e0aSJan Friedel * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _PLUGIN_H 287c478bd9Sstevel@tonic-gate #define _PLUGIN_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <security/auditd.h> 357c478bd9Sstevel@tonic-gate #include "queue.h" 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate typedef struct thd { 387c478bd9Sstevel@tonic-gate pthread_cond_t thd_cv; 397c478bd9Sstevel@tonic-gate pthread_mutex_t thd_mutex; 407c478bd9Sstevel@tonic-gate int thd_waiting; 417c478bd9Sstevel@tonic-gate } thr_data_t; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate typedef struct plg plugin_t; 447c478bd9Sstevel@tonic-gate struct plg { 457c478bd9Sstevel@tonic-gate boolean_t plg_initialized; /* if threads, pools created */ 467c478bd9Sstevel@tonic-gate boolean_t plg_reopen; /* call auditd_plugin_open */ 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * removed is 1 if last read of audit_control didn't list this 497c478bd9Sstevel@tonic-gate * plugin; it needs to be removed. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate boolean_t plg_removed; /* plugin removed */ 527c478bd9Sstevel@tonic-gate boolean_t plg_to_be_removed; /* tentative removal state */ 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate char *plg_path; /* plugin path */ 557c478bd9Sstevel@tonic-gate void *plg_dlptr; /* dynamic lib pointer */ 56*8f775e0aSJan Friedel auditd_rc_t (*plg_fplugin)(const char *, size_t, uint64_t, char **); 577c478bd9Sstevel@tonic-gate auditd_rc_t (*plg_fplugin_open)(const kva_t *, char **, char **); 587c478bd9Sstevel@tonic-gate auditd_rc_t (*plg_fplugin_close)(char **); 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate kva_t *plg_kvlist; /* plugin inputs */ 617c478bd9Sstevel@tonic-gate size_t plg_qmax; /* max queue size */ 627c478bd9Sstevel@tonic-gate size_t plg_qmin; /* min queue size */ 637c478bd9Sstevel@tonic-gate 64*8f775e0aSJan Friedel uint64_t plg_sequence; /* buffer counter */ 65*8f775e0aSJan Friedel uint64_t plg_last_seq_out; /* buffer counter (debug) */ 667c478bd9Sstevel@tonic-gate uint32_t plg_tossed; /* discards (debug) */ 677c478bd9Sstevel@tonic-gate uint32_t plg_queued; /* count buffers queued */ 687c478bd9Sstevel@tonic-gate uint32_t plg_output; /* count of buffers output */ 697c478bd9Sstevel@tonic-gate int plg_priority; /* current priority */ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate au_queue_t plg_pool; /* buffer pool */ 727c478bd9Sstevel@tonic-gate au_queue_t plg_queue; /* queue drawn from pool */ 737c478bd9Sstevel@tonic-gate int plg_q_threshold; /* max preallocated queue */ 747c478bd9Sstevel@tonic-gate audit_q_t *plg_save_q_copy; /* tmp holding for a record */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate pthread_t plg_tid; /* thread id */ 777c478bd9Sstevel@tonic-gate pthread_cond_t plg_cv; 787c478bd9Sstevel@tonic-gate pthread_mutex_t plg_mutex; 797c478bd9Sstevel@tonic-gate int plg_waiting; /* output thread wait state */ 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate int plg_cnt; /* continue policy */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate int plg_retry_time; /* retry (seconds) */ 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate plugin_t *plg_next; /* null is end of list */ 867c478bd9Sstevel@tonic-gate }; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate int auditd_thread_init(); 897c478bd9Sstevel@tonic-gate void auditd_thread_close(); 907c478bd9Sstevel@tonic-gate void auditd_exit(int); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate extern plugin_t *plugin_head; 937c478bd9Sstevel@tonic-gate extern pthread_mutex_t plugin_mutex; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate #ifdef __cplusplus 967c478bd9Sstevel@tonic-gate } 977c478bd9Sstevel@tonic-gate #endif 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #endif /* _PLUGIN_H */ 100