PERFORCE change 18292 for review

Robert Watson rwatson at freebsd.org
Sat Sep 28 19:50:49 GMT 2002


http://people.freebsd.org/~peter/p4db/chv.cgi?CH=18292

Change 18292 by rwatson at rwatson_tislabs on 2002/09/28 12:50:25

	Teach mac_partition to speak strings in kernel, removing the
	need for a special userland module to support the partition
	model.  Hand it off to generic.

Affected files ...

.. //depot/projects/trustedbsd/mac/etc/mac.conf#4 edit
.. //depot/projects/trustedbsd/mac/lib/libmac/modules/Makefile#4 edit
.. //depot/projects/trustedbsd/mac/lib/libmac/modules/mac_partition/Makefile#2 delete
.. //depot/projects/trustedbsd/mac/lib/libmac/modules/mac_partition/mac_partition.c#2 delete
.. //depot/projects/trustedbsd/mac/sys/security/mac_partition/mac_partition.c#15 edit

Differences ...

==== //depot/projects/trustedbsd/mac/etc/mac.conf#4 (text+ko) ====

@@ -17,6 +17,5 @@
 # Bind policy names to loadable shared modules
 #
 
-module mac_generic libmac_generic.so.1 biba mls, te	# Type enforcement
-module mac_partition libmac_partition.so.1		# Partition policy
+module mac_generic libmac_generic.so.1 biba mls partition te
 

==== //depot/projects/trustedbsd/mac/lib/libmac/modules/Makefile#4 (text+ko) ====

@@ -1,3 +1,3 @@
-SUBDIR		= mac_generic mac_partition
+SUBDIR		= mac_generic
 
 .include <bsd.subdir.mk>

==== //depot/projects/trustedbsd/mac/sys/security/mac_partition/mac_partition.c#15 (text+ko) ====

@@ -107,6 +107,8 @@
 mac_partition_externalize_label(struct label *label, struct mac *mac,
     struct mac_element *element, int *claimed)
 {
+	char string[MAC_MAX_LABEL_ELEMENT_DATALEN];		/* XXX */
+	size_t left, len;
 	int error;
 
 	if (strcmp(MAC_PARTITION_LABEL_NAME, element->me_name) != 0)
@@ -114,14 +116,20 @@
 
 	(*claimed)++;
 
-	if (element->me_databuflen < sizeof(long))
+	bzero(string, sizeof(string));
+	left = MAC_MAX_LABEL_ELEMENT_DATALEN;
+	len = snprintf(string, left, "%ld", SLOT(label));
+	if (len >= left)
+		return (EINVAL);
+
+	if (element->me_databuflen < strlen(string)+1)
 		return (EINVAL);
 
-	error = copyout(&SLOT(label), element->me_data, sizeof(long));
+	error = copyout(string, element->me_data, strlen(string)+1);
 	if (error)
 		return (error);
 
-	element->me_datalen = sizeof(long);
+	element->me_datalen = strlen(string)+1;
 	return (0);
 }
 
@@ -129,7 +137,8 @@
 mac_partition_internalize_label(struct label *label, struct mac *mac,
     struct mac_element *element, int *claimed)
 {
-	long long_temp;
+	char string[MAC_MAX_LABEL_ELEMENT_DATALEN];
+	long l;
 	int error;
 
 	if (strcmp(MAC_PARTITION_LABEL_NAME, element->me_name) != 0)
@@ -137,14 +146,14 @@
 
 	(*claimed)++;
 
-	if (element->me_datalen != sizeof(long))
-		return (EINVAL);
-
-	error = copyin(element->me_data, &long_temp, sizeof(long_temp));
+	error = copyinstr(element->me_data, string,
+	    MAC_MAX_LABEL_ELEMENT_DATALEN, NULL);
 	if (error)
 		return (error);
 
-	SLOT(label) = long_temp;
+	l = strtol(string, NULL, 10);
+
+	SLOT(label) = l;
 	return (0);
 }
 
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