PERFORCE change 87387 for review

Robert Watson rwatson at FreeBSD.org
Mon Nov 28 22:14:13 GMT 2005


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

Change 87387 by rwatson at rwatson_peppercorn on 2005/11/28 22:13:12

	Merge class lookup fixes from OpenBSM to audit3.

Affected files ...

.. //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_class.c#3 integrate
.. //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_flags.c#3 integrate
.. //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_token.c#5 integrate

Differences ...

==== //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_class.c#3 (text+ko) ====

@@ -146,10 +146,18 @@
 		return (NULL);
 	}
 
-	if (fgets(linestr, AU_LINE_MAX, fp) == NULL) {
-		pthread_mutex_unlock(&mutex);
-		return (NULL);
+	/*
+	 * Read until next non-comment line is found, or EOF.
+	 */
+	while (1) {
+		if (fgets(linestr, AU_LINE_MAX, fp) == NULL) {
+			pthread_mutex_unlock(&mutex);
+			return (NULL);
+		}
+		if (linestr[0] != '#')
+			break;
 	}
+
 	/* Remove trailing new line character. */
 	if ((nl = strrchr(linestr, '\n')) != NULL)
 		*nl = '\0';
@@ -180,7 +188,6 @@
 getauclassnam(const char *name)
 {
 	struct au_class_ent *c;
-	char *nl;
 
 	if (name == NULL)
 		return (NULL);
@@ -201,24 +208,16 @@
 		return (NULL);
 	}
 
-	while(fgets(linestr, AU_LINE_MAX, fp) != NULL) {
-		/* Remove trailing new line character */
-		if ((nl = strrchr(linestr, '\n')) != NULL)
-			*nl = '\0';
-
-		/* 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);
-			}
+	while ((c = getauclassent()) != NULL) {
+		if (strcmp(name, c->ac_name) == 0) {
+			pthread_mutex_unlock(&mutex);
+			return (c);
 		}
+		free_au_class_ent(c);
 	}
 
-	free_au_class_ent(c);
 	pthread_mutex_unlock(&mutex);
 	return (NULL);
-
 }
 
 /*

==== //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_flags.c#3 (text+ko) ====

@@ -28,6 +28,7 @@
 
 #include <bsm/libbsm.h>
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -45,8 +46,10 @@
 	struct au_class_ent *c;
 	char *last;
 
-	if ((auditstr == NULL) || (masks == NULL))
+	if ((auditstr == NULL) || (masks == NULL)) {
+		errno = EINVAL;
 		return (-1);
+	}
 
 	masks->am_success = 0;
 	masks->am_failure = 0;
@@ -76,8 +79,10 @@
 			else
 				ADD_TO_MASK(masks, c->ac_class, sel);
 			free_au_class_ent(c);
-		} else
+		} else {
+			errno = EINVAL;
 			return (-1);
+		}
 
 		/* Get the next class. */
 		tok = strtok_r(NULL, delim, &last);
@@ -89,6 +94,9 @@
  * Convert the au_mask_t fields into a string value.  If verbose is non-zero
  * the long flag names are used else the short (2-character)flag names are
  * used.
+ *
+ * XXXRW: If bits are specified that are not matched by any class, they are
+ * omitted rather than rejected with EINVAL.
  */
 int
 getauditflagschar(char *auditstr, au_mask_t *masks, int verbose)
@@ -97,8 +105,10 @@
 	char *strptr = auditstr;
 	u_char sel;
 
-	if ((auditstr == NULL) || (masks == NULL))
+	if ((auditstr == NULL) || (masks == NULL)) {
+		return (EINVAL);
 		return (-1);
+	}
 
 	/*
 	 * Enumerate the class entries, check if each is selected in either

==== //depot/projects/trustedbsd/audit3/contrib/openbsm/libbsm/bsm_token.c#5 (text+ko) ====

@@ -1108,8 +1108,8 @@
 }
 
 token_t *
-au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid, gid_t rgid,
-    pid_t pid, au_asid_t sid, au_tid_addr_t *tid)
+au_to_subject_ex(au_id_t auid, uid_t euid, gid_t egid, uid_t ruid,
+    gid_t rgid, pid_t pid, au_asid_t sid, au_tid_addr_t *tid)
 {
 
 	return (au_to_subject32_ex(auid, euid, egid, ruid, rgid, pid, sid,
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