From owner-p4-projects@FreeBSD.ORG Wed Jan 11 08:30:02 2006 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 EA3D716A422; Wed, 11 Jan 2006 08:30:01 +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 8B46B16A41F for ; Wed, 11 Jan 2006 08:30:01 +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 D08DB43D69 for ; Wed, 11 Jan 2006 08:29:15 +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 k0B8T1Vv055938 for ; Wed, 11 Jan 2006 08:29:01 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 k0B8T1AO055933 for perforce@freebsd.org; Wed, 11 Jan 2006 08:29:01 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 11 Jan 2006 08:29:01 GMT Message-Id: <200601110829.k0B8T1AO055933@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 89501 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: Wed, 11 Jan 2006 08:30:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=89501 Change 89501 by rwatson@rwatson_peppercorn on 2006/01/11 08:28:14 Add Chunyang Yuan to the credits as a contributor to OpenBSM. Affected files ... .. //depot/projects/trustedbsd/openbsm/README#7 edit .. //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#5 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#15 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_user.c#6 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/README#7 (text+ko) ==== @@ -58,6 +58,7 @@ Wayne Salamon Tom Rhodes Wojciech Koszek + Chunyang Yuan Contributions ==== //depot/projects/trustedbsd/openbsm/bsm/libbsm.h#5 (text+ko) ==== @@ -827,6 +827,7 @@ void endauclass(); struct au_class_ent *getauclassent(); struct au_class_ent *getauclassnam(const char *name); +struct au_class_ent *getauclassnum(au_class_t class_number); /* * Free the au_class_ent structure */ ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_audit.c#15 (text+ko) ==== ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_user.c#6 (text+ko) ==== @@ -57,7 +57,7 @@ { struct au_user_ent *u; - u = (struct au_user_ent *) malloc (sizeof(struct au_user_ent)); + u = (struct au_user_ent *) malloc(sizeof(struct au_user_ent)); if (u == NULL) return (NULL); u->au_name = (char *)malloc(AU_USER_NAME_MAX * sizeof(char)); @@ -112,13 +112,20 @@ /* * Rewind to beginning of the file */ +static void +setauuser_locked(void) +{ + + if (fp != NULL) + fseek(fp, 0, SEEK_SET); +} + void setauuser(void) { pthread_mutex_lock(&mutex); - if (fp != NULL) - fseek(fp, 0, SEEK_SET); + setauuser_locked(); pthread_mutex_unlock(&mutex); } @@ -140,41 +147,42 @@ /* * Enumerate the au_user_ent structures from the file */ -struct au_user_ent * -getauuserent(void) +static struct au_user_ent * +getauuserent_locked(void) { struct au_user_ent *u; char *nl; - pthread_mutex_lock(&mutex); - - if ((fp == NULL) && ((fp = fopen(AUDIT_USER_FILE, "r")) == NULL)) { - pthread_mutex_unlock(&mutex); + if ((fp == NULL) && ((fp = fopen(AUDIT_USER_FILE, "r")) == NULL)) return (NULL); - } - if (fgets(linestr, AU_LINE_MAX, fp) == NULL) { - pthread_mutex_unlock(&mutex); + if (fgets(linestr, AU_LINE_MAX, fp) == NULL) return (NULL); - } /* Remove new lines. */ if ((nl = strrchr(linestr, '\n')) != NULL) *nl = '\0'; u = get_user_area(); - if (u == NULL) { - pthread_mutex_unlock(&mutex); + if (u == NULL) return (NULL); - } /* Get the next structure. */ if (userfromstr(linestr, delim, u) == NULL) { destroy_user_area(u); - pthread_mutex_unlock(&mutex); return (NULL); } + return (u); +} + +struct au_user_ent * +getauuserent(void) +{ + struct au_user_ent *u; + + pthread_mutex_lock(&mutex); + u = getauuserent_locked(); pthread_mutex_unlock(&mutex); return (u); } @@ -186,40 +194,21 @@ getauusernam(const char *name) { struct au_user_ent *u; - char *nl; if (name == NULL) return (NULL); - setauuser(); - pthread_mutex_lock(&mutex); - if ((fp == NULL) && ((fp = fopen(AUDIT_USER_FILE, "r")) == NULL)) { - pthread_mutex_unlock(&mutex); - return (NULL); - } - - u = get_user_area(); - if (u == NULL) { - pthread_mutex_unlock(&mutex); - return (NULL); - } - - while (fgets(linestr, AU_LINE_MAX, fp) != NULL) { - /* Remove new lines. */ - if ((nl = strrchr(linestr, '\n')) != NULL) - *nl = '\0'; - - if (userfromstr(linestr, delim, u) != NULL) { - if (!strcmp(name, u->au_name)) { - pthread_mutex_unlock(&mutex); - return (u); - } + setauuser_locked(); + while ((u = getauuserent()) != NULL) { + if (strcmp(name, u->au_name) == 0) { + pthread_mutex_unlock(&mutex); + return (u); } + destroy_user_area(u); } - destroy_user_area(u); pthread_mutex_unlock(&mutex); return (NULL);