From 3dabba580bd939eae90efba54984d0c4de64eb3e Mon Sep 17 00:00:00 2001 From: rwatson Date: Sat, 26 Aug 2006 08:04:15 +0000 Subject: Vendor import of OpenBSM 1.0 alpha 9, with the following change history notes since the last import: OpenBSM 1.0 alpha 9 - Rename many OpenBSM-specific constants and API elements containing the strings "BSM" and "bsm" to "AUDIT" and "audit", observing that this is true for almost all existing constants and APIs. - Instead of passing a per-instance cookie directly into all audit filter APIs, pass in the audit filter daemon state pointer, which is then used by the module using an audit_filter_{get,set}cookie() API. This will allow future service APIs provided by the filter daemon to maintain their own state -- for example, per-module preselection state. OpenBSM 1.0 alpha 8 - Correct typo in definition of AUR_INT. - Adopt OpenSolaris constant values for AUDIT_* configuration flags. - Arguments to au_to_exec_args() and au_to_exec_env() no longer const. - Add kernel versions of au_to_exec_args() and au_to_exec_env(). - Fix exec argument type that is printed for env strings from 'arg' to 'env'. - New OpenBSM token version number assigned, constants added for other commonly seen version numbers. - OpenBSM-specific events assigned numbers in the 43xxx range to avoid future collisions with Solaris. Darwin events renamed to AUE_DARWIN_foo, as they are now deprecated numberings. - autoconf now detects clock_gettime(), which is not available on Darwin. - praudit output fixes relating to arg32 and arg64 tokens. - Maximum record size updated to 64k-1 to match Solaris record size limit. - Various style and comment cleanups in include files. This is an MFC candidate to RELENG_6. Obtained from: TrustedBSD Project --- contrib/openbsm/libbsm/au_token.3 | 6 +++--- contrib/openbsm/libbsm/bsm_audit.c | 32 ++++++++++++++++---------------- contrib/openbsm/libbsm/bsm_event.c | 23 ++++++++++++++--------- contrib/openbsm/libbsm/bsm_io.c | 10 +++++----- contrib/openbsm/libbsm/bsm_token.c | 22 +++++++++++----------- 5 files changed, 49 insertions(+), 44 deletions(-) (limited to 'contrib/openbsm/libbsm') diff --git a/contrib/openbsm/libbsm/au_token.3 b/contrib/openbsm/libbsm/au_token.3 index 5b2ad30..384a5b8 100644 --- a/contrib/openbsm/libbsm/au_token.3 +++ b/contrib/openbsm/libbsm/au_token.3 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $P4: //depot/projects/trustedbsd/openbsm/libbsm/au_token.3#7 $ +.\" $P4: //depot/projects/trustedbsd/openbsm/libbsm/au_token.3#8 $ .\" .Dd April 19, 2005 .Dt AU_TOKEN 3 @@ -155,9 +155,9 @@ .Ft token_t * .Fn au_to_me "void" .Ft token_t * -.Fn au_to_exec_args "const char **args" +.Fn au_to_exec_args "char **argv" .Ft token_t * -.Fn au_to_exec_env "const char **env" +.Fn au_to_exec_env "char **envp" .Ft token_t * .Fn au_to_header "int rec_size" "au_event_t e_type" "au_emod_t emod" .Ft token_t * diff --git a/contrib/openbsm/libbsm/bsm_audit.c b/contrib/openbsm/libbsm/bsm_audit.c index d959a30..2f6df41 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#26 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#28 $ */ #include @@ -54,14 +54,14 @@ static au_record_t *open_desc_table[MAX_AUDIT_RECORDS]; /* The current number of active record descriptors */ -static int bsm_rec_count = 0; +static int audit_rec_count = 0; /* * Records that can be recycled are maintained in the list given below. The * maximum number of elements that can be present in this list is bounded by * MAX_AUDIT_RECORDS. Memory allocated for these records are never freed. */ -static LIST_HEAD(, au_record) bsm_free_q; +static LIST_HEAD(, au_record) audit_free_q; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -93,15 +93,15 @@ au_open(void) pthread_mutex_lock(&mutex); - if (bsm_rec_count == 0) - LIST_INIT(&bsm_free_q); + if (audit_rec_count == 0) + LIST_INIT(&audit_free_q); /* * Find an unused descriptor, remove it from the free list, mark as * used. */ - if (!LIST_EMPTY(&bsm_free_q)) { - rec = LIST_FIRST(&bsm_free_q); + if (!LIST_EMPTY(&audit_free_q)) { + rec = LIST_FIRST(&audit_free_q); rec->used = 1; LIST_REMOVE(rec, au_rec_q); } @@ -125,7 +125,7 @@ au_open(void) pthread_mutex_lock(&mutex); - if (bsm_rec_count == MAX_AUDIT_RECORDS) { + if (audit_rec_count == MAX_AUDIT_RECORDS) { pthread_mutex_unlock(&mutex); free(rec->data); free(rec); @@ -134,9 +134,9 @@ au_open(void) errno = ENOMEM; return (-1); } - rec->desc = bsm_rec_count; - open_desc_table[bsm_rec_count] = rec; - bsm_rec_count++; + rec->desc = audit_rec_count; + open_desc_table[audit_rec_count] = rec; + audit_rec_count++; pthread_mutex_unlock(&mutex); @@ -174,7 +174,7 @@ au_write(int d, token_t *tok) return (-1); /* Invalid descriptor */ } - if (rec->len + tok->len + BSM_TRAILER_SIZE > MAX_AUDIT_RECORD_SIZE) { + if (rec->len + tok->len + AUDIT_TRAILER_SIZE > MAX_AUDIT_RECORD_SIZE) { errno = ENOMEM; return (-1); } @@ -208,7 +208,7 @@ au_assemble(au_record_t *rec, short event) u_char *dptr; int error; - tot_rec_size = rec->len + BSM_HEADER_SIZE + BSM_TRAILER_SIZE; + tot_rec_size = rec->len + AUDIT_HEADER_SIZE + AUDIT_TRAILER_SIZE; header = au_to_header32(tot_rec_size, event, 0); if (header == NULL) return (-1); @@ -257,7 +257,7 @@ au_teardown(au_record_t *rec) pthread_mutex_lock(&mutex); /* Add the record to the freelist tail */ - LIST_INSERT_HEAD(&bsm_free_q, rec, au_rec_q); + LIST_INSERT_HEAD(&audit_free_q, rec, au_rec_q); pthread_mutex_unlock(&mutex); } @@ -285,7 +285,7 @@ au_close(int d, int keep, short event) goto cleanup; } - tot_rec_size = rec->len + BSM_HEADER_SIZE + BSM_TRAILER_SIZE; + tot_rec_size = rec->len + AUDIT_HEADER_SIZE + AUDIT_TRAILER_SIZE; if (tot_rec_size > MAX_AUDIT_RECORD_SIZE) { /* @@ -335,7 +335,7 @@ au_close_buffer(int d, short event, u_char *buffer, size_t *buflen) } retval = 0; - tot_rec_size = rec->len + BSM_HEADER_SIZE + BSM_TRAILER_SIZE; + tot_rec_size = rec->len + AUDIT_HEADER_SIZE + AUDIT_TRAILER_SIZE; if ((tot_rec_size > MAX_AUDIT_RECORD_SIZE) || (tot_rec_size > *buflen)) { /* diff --git a/contrib/openbsm/libbsm/bsm_event.c b/contrib/openbsm/libbsm/bsm_event.c index 6e22e4c..6dd4db4 100644 --- a/contrib/openbsm/libbsm/bsm_event.c +++ b/contrib/openbsm/libbsm/bsm_event.c @@ -27,7 +27,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_event.c#11 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_event.c#12 $ */ #include @@ -62,27 +62,32 @@ eventfromstr(char *str, struct au_event_ent *e) evdesc = strtok_r(NULL, eventdelim, &last); evclass = strtok_r(NULL, eventdelim, &last); - if ((evno == NULL) || (evname == NULL) || (evdesc == NULL) || - (evclass == NULL)) + if ((evno == NULL) || (evname == NULL)) return (NULL); if (strlen(evname) >= AU_EVENT_NAME_MAX) return (NULL); strcpy(e->ae_name, evname); - if (strlen(evdesc) >= AU_EVENT_DESC_MAX) - return (NULL); - strcpy(e->ae_desc, evdesc); + if (evdesc != NULL) { + if (strlen(evdesc) >= AU_EVENT_DESC_MAX) + return (NULL); + strcpy(e->ae_desc, evdesc); + } else + strcpy(e->ae_desc, ""); e->ae_number = atoi(evno); /* * Find out the mask that corresponds to the given list of classes. */ - if (getauditflagsbin(evclass, &evmask) != 0) + if (evclass != NULL) { + if (getauditflagsbin(evclass, &evmask) != 0) + e->ae_class = AU_NULL; + else + e->ae_class = evmask.am_success; + } else e->ae_class = AU_NULL; - else - e->ae_class = evmask.am_success; return (e); } diff --git a/contrib/openbsm/libbsm/bsm_io.c b/contrib/openbsm/libbsm/bsm_io.c index 5f678fb..30639e6 100644 --- a/contrib/openbsm/libbsm/bsm_io.c +++ b/contrib/openbsm/libbsm/bsm_io.c @@ -31,7 +31,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_io.c#37 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#40 $ */ #include @@ -820,7 +820,7 @@ print_arg32_tok(FILE *fp, tokenstr_t *tok, char *del, char raw, print_delim(fp, del); print_1_byte(fp, tok->tt.arg32.no, "%u"); print_delim(fp, del); - print_4_bytes(fp, tok->tt.arg32.val, "%#x"); + print_4_bytes(fp, tok->tt.arg32.val, "0x%x"); print_delim(fp, del); print_string(fp, tok->tt.arg32.text, tok->tt.arg32.len); } @@ -859,7 +859,7 @@ print_arg64_tok(FILE *fp, tokenstr_t *tok, char *del, char raw, print_delim(fp, del); print_1_byte(fp, tok->tt.arg64.no, "%u"); print_delim(fp, del); - print_8_bytes(fp, tok->tt.arg64.val, "%#llx"); + print_8_bytes(fp, tok->tt.arg64.val, "0x%llx"); print_delim(fp, del); print_string(fp, tok->tt.arg64.text, tok->tt.arg64.len); } @@ -1259,7 +1259,7 @@ print_execenv_tok(FILE *fp, tokenstr_t *tok, char *del, char raw, { int i; - print_tok_type(fp, tok->id, "exec arg", raw); + print_tok_type(fp, tok->id, "exec env", raw); for (i = 0; i< tok->tt.execenv.count; i++) { print_delim(fp, del); print_string(fp, tok->tt.execenv.text[i], @@ -2448,7 +2448,7 @@ fetch_invalid_tok(tokenstr_t *tok, char *buf, int len) int err = 0; int recoversize; - recoversize = len - (tok->len + BSM_TRAILER_SIZE); + recoversize = len - (tok->len + AUDIT_TRAILER_SIZE); if (recoversize <= 0) return (-1); diff --git a/contrib/openbsm/libbsm/bsm_token.c b/contrib/openbsm/libbsm/bsm_token.c index 7512c42..f90cbc9 100644 --- a/contrib/openbsm/libbsm/bsm_token.c +++ b/contrib/openbsm/libbsm/bsm_token.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_token.c#48 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#51 $ */ #include @@ -309,7 +309,7 @@ token_t * au_to_groups(int *groups) { - return (au_to_newgroups(BSM_MAX_GROUPS, groups)); + return (au_to_newgroups(AUDIT_MAX_GROUPS, groups)); } /* @@ -1055,7 +1055,7 @@ au_to_me(void) * text count null-terminated strings */ token_t * -au_to_exec_args(const char **args) +au_to_exec_args(char **argv) { token_t *t; u_char *dptr = NULL; @@ -1063,7 +1063,7 @@ au_to_exec_args(const char **args) int i, count = 0; size_t totlen = 0; - nextarg = *args; + nextarg = *argv; while (nextarg != NULL) { int nextlen; @@ -1071,7 +1071,7 @@ au_to_exec_args(const char **args) nextlen = strlen(nextarg); totlen += nextlen + 1; count++; - nextarg = *(args + count); + nextarg = *(argv + count); } totlen += count * sizeof(char); /* nul terminations. */ @@ -1083,7 +1083,7 @@ au_to_exec_args(const char **args) ADD_U_INT32(dptr, count); for (i = 0; i < count; i++) { - nextarg = *(args + i); + nextarg = *(argv + i); ADD_MEM(dptr, nextarg, strlen(nextarg) + 1); } @@ -1096,7 +1096,7 @@ au_to_exec_args(const char **args) * text count null-terminated strings */ token_t * -au_to_exec_env(const char **env) +au_to_exec_env(char **envp) { token_t *t; u_char *dptr = NULL; @@ -1104,7 +1104,7 @@ au_to_exec_env(const char **env) size_t totlen = 0; const char *nextenv; - nextenv = *env; + nextenv = *envp; while (nextenv != NULL) { int nextlen; @@ -1112,7 +1112,7 @@ au_to_exec_env(const char **env) nextlen = strlen(nextenv); totlen += nextlen + 1; count++; - nextenv = *(env + count); + nextenv = *(envp + count); } totlen += sizeof(char) * count; @@ -1124,7 +1124,7 @@ au_to_exec_env(const char **env) ADD_U_INT32(dptr, count); for (i = 0; i < count; i++) { - nextenv = *(env + i); + nextenv = *(envp + i); ADD_MEM(dptr, nextenv, strlen(nextenv) + 1); } @@ -1155,7 +1155,7 @@ au_to_header32_tm(int rec_size, au_event_t e_type, au_emod_t e_mod, ADD_U_CHAR(dptr, AUT_HEADER32); ADD_U_INT32(dptr, rec_size); - ADD_U_CHAR(dptr, HEADER_VERSION); + ADD_U_CHAR(dptr, AUDIT_HEADER_VERSION_OPENBSM); ADD_U_INT16(dptr, e_type); ADD_U_INT16(dptr, e_mod); -- cgit v1.1