Date: Sat, 30 Apr 2005 13:35:57 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 76273 for review Message-ID: <200504301335.j3UDZvxg062640@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=76273 Change 76273 by rwatson@rwatson_paprika on 2005/04/30 13:34:57 Remove trailing white space. Affected files ... .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#11 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#2 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#3 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_event.c#2 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_flags.c#3 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_io.c#6 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_mask.c#3 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_notify.c#4 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#10 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_user.c#3 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_wrappers.c#6 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#11 (text+ko) ==== @@ -2,19 +2,19 @@ * Copyright (c) 2004, Apple Computer, Inc. * Copyright (c) 2005 Robert N. M. Watson * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -40,23 +40,23 @@ #include <string.h> /* array of used descriptors */ -static au_record_t* open_desc_table[MAX_AUDIT_RECORDS]; +static au_record_t* open_desc_table[MAX_AUDIT_RECORDS]; -/* The current number of active record descriptors */ -static int bsm_rec_count = 0; -/* +/* The current number of active record descriptors */ +static int bsm_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 - */ + * freed + */ static LIST_HEAD(, au_record) bsm_free_q; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -/* - * This call frees a token_t and its internal data. +/* + * This call frees a token_t and its internal data. */ void au_free_token(token_t *tok) @@ -70,39 +70,39 @@ } /* - * This call reserves memory for the audit record. + * This call reserves memory for the audit record. * Memory must be guaranteed before any auditable event can be - * generated. + * generated. * The au_record_t structure maintains a reference to the - * memory allocated above and also the list of tokens associated + * memory allocated above and also the list of tokens associated * with this record - * Descriptors are recyled once the records are added to the audit - * trail following au_close(). - */ + * Descriptors are recyled once the records are added to the audit + * trail following au_close(). + */ int au_open(void) -{ +{ au_record_t *rec = NULL; - + pthread_mutex_lock(&mutex); if(bsm_rec_count == 0) { LIST_INIT(&bsm_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); rec->used = 1; LIST_REMOVE(rec, au_rec_q); - } + } pthread_mutex_unlock(&mutex); if(rec == NULL) { /* - * Create a new au_record_t if no descriptors are available + * Create a new au_record_t if no descriptors are available */ rec = (au_record_t *) malloc (sizeof(au_record_t)); if(rec == NULL) { @@ -148,18 +148,18 @@ * * Don't permit writing more to the buffer than would let the trailer be * appended later. - */ + */ int au_write(int d, token_t *tok) { au_record_t *rec; - + if(tok == NULL) { errno = EINVAL; return -1; /* Invalid Token */ - } + } /* Write the token to the record descriptor */ - rec = open_desc_table[d]; + rec = open_desc_table[d]; if((rec == NULL) || (rec->used == 0)) { errno = EINVAL; return -1; /* Invalid descriptor */ @@ -171,15 +171,15 @@ } /* Add the token to the tail */ - /* + /* * XXX Not locking here -- we should not be writing to * XXX the same descriptor from different threads - */ + */ TAILQ_INSERT_TAIL(&rec->token_q, tok, tokens); rec->len += tok->len; /* grow record length by token size bytes */ - - /* Token should not be available after this call */ + + /* Token should not be available after this call */ tok = NULL; return 0; /* Success */ } @@ -240,10 +240,10 @@ TAILQ_REMOVE(&rec->token_q, tok, tokens); free(tok->t_data); free(tok); - } + } rec->used = 0; - rec->len = 0; + rec->len = 0; pthread_mutex_lock(&mutex); @@ -255,7 +255,7 @@ /* * Add the header token, identify any missing tokens - * Write out the tokens to the record memory and finally, + * Write out the tokens to the record memory and finally, * call audit */ int au_close(int d, int keep, short event) @@ -263,7 +263,7 @@ au_record_t *rec; size_t tot_rec_size; int retval = 0; - + rec = open_desc_table[d]; if((rec == NULL) || (rec->used == 0)) { errno = EINVAL; @@ -275,7 +275,7 @@ goto cleanup; } - + tot_rec_size = rec->len + BSM_HEADER_SIZE + BSM_TRAILER_SIZE; if (tot_rec_size > MAX_AUDIT_RECORD_SIZE) { @@ -304,7 +304,7 @@ cleanup: /* CLEANUP */ au_teardown(rec); - return retval; + return retval; } /* ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_class.c#2 (text+ko) ==== @@ -1,18 +1,18 @@ /* * Copyright (c) 2004, Apple Computer, Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -34,9 +34,9 @@ #include <libbsm.h> /* - * Parse the contents of the audit_class file to return + * Parse the contents of the audit_class file to return * struct au_class_ent entries - */ + */ static FILE *fp = NULL; static char linestr[AU_LINE_MAX]; static char *delim = ":"; @@ -46,19 +46,19 @@ /* * XXX The reentrant versions of the following functions is TBD - * XXX struct au_class_ent *getclassent_r(au_class_ent_t *class_int); - * XXX struct au_class_ent *getclassnam_r(au_class_ent_t *class_int, const char *name); + * XXX struct au_class_ent *getclassent_r(au_class_ent_t *class_int); + * XXX struct au_class_ent *getclassnam_r(au_class_ent_t *class_int, const char *name); */ /* * Allocate a au_class_ent structure - */ + */ static struct au_class_ent *get_class_area() { struct au_class_ent *c; - + c = (struct au_class_ent *) malloc (sizeof(struct au_class_ent)); if(c == NULL) { return NULL; @@ -81,7 +81,7 @@ /* * Free the au_class_ent structure - */ + */ void free_au_class_ent(struct au_class_ent *c) { if (c) @@ -97,27 +97,27 @@ /* * Parse a single line from the audit_class file passed in str * to the struct au_class_ent elements; store the result in c - */ -static struct au_class_ent *classfromstr(char *str, char *delim, struct au_class_ent *c) + */ +static struct au_class_ent *classfromstr(char *str, char *delim, struct au_class_ent *c) { char *classname, *classdesc, *classflag; char *last; - /* each line contains flag:name:desc */ + /* each line contains flag:name:desc */ classflag = strtok_r(str, delim, &last); classname = strtok_r(NULL, delim, &last); classdesc = strtok_r(NULL, delim, &last); - if((classflag == NULL) + if((classflag == NULL) || (classname == NULL) || (classdesc == NULL)) { return NULL; - } + } /* * Check for very large classnames - */ + */ if(strlen(classname) >= AU_CLASS_NAME_MAX) { return NULL; } @@ -126,7 +126,7 @@ /* * Check for very large class description - */ + */ if(strlen(classdesc) >= AU_CLASS_DESC_MAX) { return NULL; } @@ -140,18 +140,18 @@ /* * Return the next au_class_ent structure from the file * setauclass should be called before invoking this function - * for the first time - */ + * for the first time + */ struct au_class_ent *getauclassent() { struct au_class_ent *c; - char *tokptr, *nl; - + char *tokptr, *nl; + pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) { - + pthread_mutex_unlock(&mutex); return NULL; } @@ -165,9 +165,9 @@ if((nl = strrchr(linestr, '\n')) != NULL) { *nl = '\0'; } - + tokptr = linestr; - + c = get_class_area(); /* allocate */ if(c == NULL) { @@ -175,7 +175,7 @@ return NULL; } - /* parse tokptr to au_class_ent components */ + /* parse tokptr to au_class_ent components */ if(classfromstr(tokptr, delim, c) == NULL) { free_au_class_ent(c); @@ -190,7 +190,7 @@ /* * Return the next au_class_entry having the given class name - */ + */ struct au_class_ent *getauclassnam(const char *name) { struct au_class_ent *c; @@ -202,17 +202,17 @@ /* Rewind to beginning of file */ setauclass(); - + pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_CLASS_FILE, "r")) == NULL)) { - + pthread_mutex_unlock(&mutex); return NULL; } - - c = get_class_area(); /* allocate */ + + c = get_class_area(); /* allocate */ if(c == NULL) { pthread_mutex_unlock(&mutex); @@ -224,14 +224,14 @@ *nl = '\0'; } - /* parse tokptr to au_class_ent components */ + /* parse tokptr to au_class_ent components */ if(classfromstr(linestr, delim, c) != NULL) { if(!strcmp(name, c->ac_name)) { - + pthread_mutex_unlock(&mutex); return c; } - } + } } free_au_class_ent(c); @@ -243,7 +243,7 @@ /* * Rewind to the beginning of the enumeration - */ + */ void setauclass() { pthread_mutex_lock(&mutex); @@ -256,12 +256,12 @@ } /* - * audit_class processing is complete; close any open files - */ + * audit_class processing is complete; close any open files + */ void endauclass() { pthread_mutex_lock(&mutex); - + if(fp != NULL) { fclose(fp); fp = NULL; ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#3 (text+ko) ==== @@ -1,18 +1,18 @@ /* * Copyright (c) 2004, Apple Computer, Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -34,10 +34,10 @@ #include <libbsm.h> -/* - * Parse the contents of the audit_control file to return +/* + * Parse the contents of the audit_control file to return * the audit control parameters - */ + */ static FILE *fp = NULL; static char linestr[AU_LINE_MAX]; static char *delim = ":"; @@ -47,21 +47,21 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -/* - * Returns the string value corresponding to the given label +/* + * Returns the string value corresponding to the given label * from the configuration file - */ + */ static int getstrfromtype(char *name, char **str) { char *type, *nl; char *tokptr; char *last; - + *str = NULL; pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_CONTROL_FILE, "r")) == NULL)) { pthread_mutex_unlock(&mutex); @@ -90,16 +90,16 @@ } return 0; /* Success */ } - } + } } pthread_mutex_unlock(&mutex); return 0; /* EOF */ } -/* - * Rewind the file pointer to beginning - */ +/* + * Rewind the file pointer to beginning + */ void setac() { pthread_mutex_lock(&mutex); @@ -114,11 +114,11 @@ /* * Close the audit_control file - */ + */ void endac() { pthread_mutex_lock(&mutex); - + ptrmoved = 1; if(fp != NULL) { fclose(fp); @@ -130,12 +130,12 @@ /* * Return audit directory information from the audit control file - */ + */ int getacdir(char *name, int len) { char *dir; int ret = 0; - + if(name == NULL) { errno = EINVAL; return -2; @@ -143,25 +143,25 @@ pthread_mutex_lock(&mutex); - /* - * Check if another function was called between - * successive calls to getacdir + /* + * Check if another function was called between + * successive calls to getacdir */ if(inacdir && ptrmoved) { ptrmoved = 0; if(fp != NULL) { - fseek(fp, 0, SEEK_SET); + fseek(fp, 0, SEEK_SET); } - - ret = 2; + + ret = 2; } - + pthread_mutex_unlock(&mutex); - + if(getstrfromtype(DIR_CONTROL_ENTRY, &dir) == 1) { return -3; } - + if(dir == NULL){ return -1; @@ -171,20 +171,20 @@ return -3; } - strcpy(name, dir); + strcpy(name, dir); return ret; } /* * Return the minimum free diskspace value from the audit control file - */ + */ int getacmin(int *min_val) { char *min; setac(); - + if(min_val == NULL) { errno = EINVAL; return -2; @@ -193,7 +193,7 @@ if(getstrfromtype(MINFREE_CONTROL_ENTRY, &min) == 1) { return -3; } - + if(min == NULL) { return 1; } @@ -205,13 +205,13 @@ /* * Return the system audit value from the audit contol file - */ + */ int getacflg(char *auditstr, int len) { char *str; setac(); - + if(auditstr == NULL) { errno = EINVAL; return -2; @@ -220,7 +220,7 @@ if(getstrfromtype(FLAGS_CONTROL_ENTRY, &str) == 1) { return -3; } - + if(str == NULL) { return 1; } @@ -229,21 +229,20 @@ return -3; } - strcpy(auditstr, str); + strcpy(auditstr, str); return 0; } - /* * Return the non attributable flags from the audit contol file - */ + */ int getacna(char *auditstr, int len) { char *str; setac(); - + if(auditstr == NULL) { errno = EINVAL; return -2; @@ -261,8 +260,7 @@ return -3; } - strcpy(auditstr, str); + strcpy(auditstr, str); return 0; } - ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_event.c#2 (text+ko) ==== @@ -1,18 +1,18 @@ /* * Copyright (c) 2004, Apple Computer, Inc. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -36,7 +36,7 @@ /* * Parse the contents of the audit_event file to return * au_event_ent entries - */ + */ static FILE *fp = NULL; static char linestr[AU_LINE_MAX]; static char *delim = ":"; @@ -51,13 +51,13 @@ */ -/* +/* * Allocate an au_event_ent structure - */ + */ static struct au_event_ent *get_event_area() { struct au_event_ent *e; - + e = (struct au_event_ent *) malloc (sizeof(struct au_event_ent)); if(e == NULL) { return NULL; @@ -79,41 +79,41 @@ /* * Free the au_event_ent structure - */ + */ void free_au_event_ent(struct au_event_ent *e) { if (e) { - if (e->ae_name) + if (e->ae_name) free(e->ae_name); - if (e->ae_desc) + if (e->ae_desc) free(e->ae_desc); free(e); } } -/* - * Parse one line from the audit_event file into +/* + * Parse one line from the audit_event file into * the au_event_ent structure - */ -static struct au_event_ent *eventfromstr(char *str, char *delim, struct au_event_ent *e) + */ +static struct au_event_ent *eventfromstr(char *str, char *delim, struct au_event_ent *e) { char *evno, *evname, *evdesc, *evclass; struct au_mask evmask; char *last; - + evno = strtok_r(str, delim, &last); evname = strtok_r(NULL, delim, &last); evdesc = strtok_r(NULL, delim, &last); evclass = strtok_r(NULL, delim, &last); - if((evno == NULL) + if((evno == NULL) || (evname == NULL) || (evdesc == NULL) || (evclass == NULL)) { return NULL; - } + } if(strlen(evname) >= AU_EVENT_NAME_MAX) { return NULL; @@ -124,24 +124,24 @@ return NULL; } strcpy(e->ae_desc, evdesc); - + e->ae_number = atoi(evno); - /* - * find out the mask that corresponds - * to the given list of classes. - */ + /* + * find out the mask that corresponds + * to the given list of classes. + */ if(getauditflagsbin(evclass, &evmask) != 0) e->ae_class = AU_NULL; - else - e->ae_class = evmask.am_success; + else + e->ae_class = evmask.am_success; return e; } /* * Rewind the audit_event file - */ + */ void setauevent() { pthread_mutex_lock(&mutex); @@ -155,11 +155,11 @@ /* * Close the open file pointers - */ + */ void endauevent() { pthread_mutex_lock(&mutex); - + if(fp != NULL) { fclose(fp); fp = NULL; @@ -170,7 +170,7 @@ /* * Enumerate the au_event_ent entries - */ + */ struct au_event_ent *getauevent() { struct au_event_ent *e; @@ -178,9 +178,9 @@ pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_EVENT_FILE, "r")) == NULL)) { - + pthread_mutex_unlock(&mutex); return NULL; } @@ -202,7 +202,7 @@ return NULL; } - /* Get the next event structure */ + /* Get the next event structure */ if(eventfromstr(linestr, delim, e) == NULL) { free_au_event_ent(e); @@ -217,7 +217,7 @@ /* * Search for an audit event structure having the given event name - */ + */ struct au_event_ent *getauevnam(char *name) { struct au_event_ent *e; @@ -226,20 +226,20 @@ if(name == NULL) { return NULL; } - + /* Rewind to beginning of the file */ setauevent(); - + pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_EVENT_FILE, "r")) == NULL)) { - + pthread_mutex_unlock(&mutex); return NULL; } - e = get_event_area(); + e = get_event_area(); if(e == NULL) { pthread_mutex_unlock(&mutex); @@ -251,14 +251,14 @@ if((nl = strrchr(linestr, '\n')) != NULL) { *nl = '\0'; } - + if(eventfromstr(linestr, delim, e) != NULL) { if(!strcmp(name, e->ae_name)) { - + pthread_mutex_unlock(&mutex); return e; } - } + } } free_au_event_ent(e); @@ -271,7 +271,7 @@ /* * Search for an audit event structure having the given event number - */ + */ struct au_event_ent *getauevnum(au_event_t event_number) { struct au_event_ent *e; @@ -282,14 +282,14 @@ pthread_mutex_lock(&mutex); - if((fp == NULL) + if((fp == NULL) && ((fp = fopen(AUDIT_EVENT_FILE, "r")) == NULL)) { - + pthread_mutex_unlock(&mutex); return NULL; } - e = get_event_area(); + e = get_event_area(); if(e == NULL) { pthread_mutex_unlock(&mutex); @@ -301,14 +301,14 @@ if((nl = strrchr(linestr, '\n')) != NULL) { *nl = '\0'; } - + if(eventfromstr(linestr, delim, e) != NULL) { if(event_number == e->ae_number) { - + pthread_mutex_unlock(&mutex); return e; } - } + } } free_au_event_ent(e); @@ -319,9 +319,9 @@ } /* - * Search for an audit_event entry with a given event_name + * Search for an audit_event entry with a given event_name * and returns the corresponding event number - */ + */ au_event_t *getauevnonam(char *event_name) { struct au_event_ent *e; @@ -331,16 +331,16 @@ if(e != NULL) { n = (au_event_t *) malloc (sizeof(au_event_t)); >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504301335.j3UDZvxg062640>