From owner-p4-projects@FreeBSD.ORG Mon May 30 22:16:25 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 37FCE16A44F; Mon, 30 May 2005 22:16:24 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D3E7C16A43C for ; Mon, 30 May 2005 22:16:23 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C01543D54 for ; Mon, 30 May 2005 22:16:23 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j4UMGNCm071212 for ; Mon, 30 May 2005 22:16:23 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j4UMGNdu071208 for perforce@freebsd.org; Mon, 30 May 2005 22:16:23 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 30 May 2005 22:16:23 GMT Message-Id: <200505302216.j4UMGNdu071208@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 77747 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2005 22:16:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=77747 Change 77747 by rwatson@rwatson_paprika on 2005/05/30 22:15:44 Converge on BSD style(9). Affected files ... .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#4 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#4 (text+ko) ==== @@ -35,23 +35,24 @@ #include /* - * Parse the contents of the audit_control file to return - * the audit control parameters + * 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 = ":"; +static FILE *fp = NULL; +static char linestr[AU_LINE_MAX]; +static char *delim = ":"; -static char inacdir = 0; -static char ptrmoved = 0; +static char inacdir = 0; +static char ptrmoved = 0; -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* - * Returns the string value corresponding to the given label - * from the configuration file + * Returns the string value corresponding to the given label from the + * configuration file. */ -static int getstrfromtype(char *name, char **str) +static int +getstrfromtype(char *name, char **str) { char *type, *nl; char *tokptr; @@ -61,84 +62,77 @@ pthread_mutex_lock(&mutex); - if((fp == NULL) - && ((fp = fopen(AUDIT_CONTROL_FILE, "r")) == NULL)) { - + if ((fp == NULL) && ((fp = fopen(AUDIT_CONTROL_FILE, "r")) == + NULL)) { pthread_mutex_unlock(&mutex); - return 0; /* Error */ + return (0); /* Error */ } - /* Search for the line beginning with the given name */ - while(fgets(linestr, AU_LINE_MAX, fp) != NULL) { - - /* Remove trailing new line character */ - if((nl = strrchr(linestr, '\n')) != NULL) { + /* Search for the line beginning with the given name. */ + while (fgets(linestr, AU_LINE_MAX, fp) != NULL) { + /* Remove trailing new line character. */ + if ((nl = strrchr(linestr, '\n')) != NULL) *nl = '\0'; - } tokptr = linestr; - if((type = strtok_r(tokptr, delim, &last)) != NULL) { - if(!strcmp(name, type)) { - - /* Found matching name */ + if ((type = strtok_r(tokptr, delim, &last)) != NULL) { + if (!strcmp(name, type)) { + /* Found matching name. */ *str = strtok_r(NULL, delim, &last); - pthread_mutex_unlock(&mutex); - - if(*str == NULL) { - return 1; /* Parse error in file */ - } - return 0; /* Success */ + if (*str == NULL) + return (1); /* Parse error in file */ + return (0); /* Success */ } } } pthread_mutex_unlock(&mutex); - return 0; /* EOF */ + return (0); /* EOF */ } /* - * Rewind the file pointer to beginning + * Rewind the file pointer to beginning. */ -void setac() +void +setac(void) { + pthread_mutex_lock(&mutex); - ptrmoved = 1; - if(fp != NULL) { + if (fp != NULL) fseek(fp, 0, SEEK_SET); - } - pthread_mutex_unlock(&mutex); } /* * Close the audit_control file */ -void endac() +void +endac(void) { + pthread_mutex_lock(&mutex); - ptrmoved = 1; - if(fp != NULL) { + if (fp != NULL) { fclose(fp); fp = NULL; } - pthread_mutex_unlock(&mutex); } /* - * Return audit directory information from the audit control file + * Return audit directory information from the audit control file. */ -int getacdir(char *name, int len) +int +getacdir(char *name, int len) { char *dir; int ret = 0; - if(name == NULL) { + if (name == NULL) { errno = EINVAL; - return -2; + return (-2); } pthread_mutex_lock(&mutex); @@ -147,120 +141,109 @@ * Check if another function was called between * successive calls to getacdir */ - if(inacdir && ptrmoved) { + if (inacdir && ptrmoved) { ptrmoved = 0; - if(fp != NULL) { + if (fp != NULL) fseek(fp, 0, SEEK_SET); - } - ret = 2; } pthread_mutex_unlock(&mutex); - if(getstrfromtype(DIR_CONTROL_ENTRY, &dir) == 1) { - return -3; - } + if (getstrfromtype(DIR_CONTROL_ENTRY, &dir) == 1) + return (-3); - if(dir == NULL){ + if (dir == NULL) + return (-1); - return -1; - } - - if(strlen(dir) >= len) { - return -3; - } + if (strlen(dir) >= len) + return (-3); strcpy(name, dir); - return ret; + return (ret); } /* * Return the minimum free diskspace value from the audit control file */ -int getacmin(int *min_val) +int +getacmin(int *min_val) { char *min; setac(); - if(min_val == NULL) { + if (min_val == NULL) { errno = EINVAL; - return -2; + return (-2); } - if(getstrfromtype(MINFREE_CONTROL_ENTRY, &min) == 1) { - return -3; - } + if (getstrfromtype(MINFREE_CONTROL_ENTRY, &min) == 1) + return (-3); - if(min == NULL) { - return 1; - } + if (min == NULL) + return (1); *min_val = atoi(min); - return 0; + return (0); } /* - * Return the system audit value from the audit contol file + * Return the system audit value from the audit contol file. */ -int getacflg(char *auditstr, int len) +int +getacflg(char *auditstr, int len) { char *str; setac(); - if(auditstr == NULL) { + if (auditstr == NULL) { errno = EINVAL; - return -2; + return (-2); } - if(getstrfromtype(FLAGS_CONTROL_ENTRY, &str) == 1) { - return -3; - } + if (getstrfromtype(FLAGS_CONTROL_ENTRY, &str) == 1) + return (-3); - if(str == NULL) { - return 1; - } + if (str == NULL) + return (1); - if(strlen(str) >= len) { - return -3; - } + if (strlen(str) >= len) + return (-3); strcpy(auditstr, str); - return 0; + return (0); } /* - * Return the non attributable flags from the audit contol file + * Return the non attributable flags from the audit contol file. */ -int getacna(char *auditstr, int len) +int +getacna(char *auditstr, int len) { char *str; setac(); - if(auditstr == NULL) { + if (auditstr == NULL) { errno = EINVAL; - return -2; + return (-2); } - if(getstrfromtype(NA_CONTROL_ENTRY, &str) == 1) { - return -3; - } + if (getstrfromtype(NA_CONTROL_ENTRY, &str) == 1) + return (-3); - if(str == NULL) { - return 1; - } + if (str == NULL) + return (1); - if(strlen(str) >= len) { - return -3; - } + if (strlen(str) >= len) + return (-3); strcpy(auditstr, str); - return 0; + return (0); }