PERFORCE change 89501 for review

Robert Watson rwatson at FreeBSD.org
Wed Jan 11 08:29:01 GMT 2006


http://perforce.freebsd.org/chv.cgi?CH=89501

Change 89501 by rwatson at 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);
 
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list