From owner-p4-projects Sat Sep 28 12:52:24 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B0DBE37B404; Sat, 28 Sep 2002 12:52:20 -0700 (PDT) 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 5D6DF37B401 for ; Sat, 28 Sep 2002 12:52:20 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E940543E88 for ; Sat, 28 Sep 2002 12:52:19 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g8SJq9Co002892 for ; Sat, 28 Sep 2002 12:52:19 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g8SJonql001433 for perforce@freebsd.org; Sat, 28 Sep 2002 12:50:49 -0700 (PDT) Date: Sat, 28 Sep 2002 12:50:49 -0700 (PDT) Message-Id: <200209281950.g8SJonql001433@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 18292 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=18292 Change 18292 by rwatson@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 ==== //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@FreeBSD.org with "unsubscribe p4-projects" in the body of the message