1/*- 2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson 3 * Copyright (c) 2001, 2002, 2003 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed by Robert Watson for the TrustedBSD Project. 7 * 8 * This software was developed for the FreeBSD Project in part by Network --- 17 unchanged lines hidden (view full) --- 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * |
34 * $FreeBSD: head/sys/security/mac_biba/mac_biba.c 116701 2003-06-23 01:26:34Z rwatson $ |
35 */ 36 37/* 38 * Developed by the TrustedBSD Project. 39 * Biba fixed label mandatory integrity policy. 40 */ 41 42#include <sys/types.h> --- 528 unchanged lines hidden (view full) --- 571 572 default: 573 panic("mac_biba_element_to_string: invalid type (%d)", 574 element->mbe_type); 575 } 576} 577 578/* |
579 * mac_biba_to_string() converts a Biba label to a string, and places 580 * the results in the passed sbuf. It returns 0 on success, or EINVAL 581 * if there isn't room in the sbuf. Note: the sbuf will be modified 582 * even in a failure case, so the caller may need to revert the sbuf 583 * by restoring the offset if that's undesired. |
584 */ 585static int |
586mac_biba_to_string(struct sbuf *sb, struct mac_biba *mac_biba) |
587{ |
588 |
589 if (mac_biba->mb_flags & MAC_BIBA_FLAG_SINGLE) { |
590 if (mac_biba_element_to_string(sb, &mac_biba->mb_single) |
591 == -1) 592 return (EINVAL); 593 } 594 595 if (mac_biba->mb_flags & MAC_BIBA_FLAG_RANGE) { |
596 if (sbuf_putc(sb, '(') == -1) |
597 return (EINVAL); 598 |
599 if (mac_biba_element_to_string(sb, &mac_biba->mb_rangelow) |
600 == -1) 601 return (EINVAL); 602 |
603 if (sbuf_putc(sb, '-') == -1) |
604 return (EINVAL); 605 |
606 if (mac_biba_element_to_string(sb, &mac_biba->mb_rangehigh) |
607 == -1) 608 return (EINVAL); 609 |
610 if (sbuf_putc(sb, ')') == -1) |
611 return (EINVAL); 612 } 613 |
614 return (0); 615} 616 617static int 618mac_biba_externalize_label(struct label *label, char *element_name, |
619 struct sbuf *sb, int *claimed) |
620{ 621 struct mac_biba *mac_biba; |
622 623 if (strcmp(MAC_BIBA_LABEL_NAME, element_name) != 0) 624 return (0); 625 626 (*claimed)++; 627 628 mac_biba = SLOT(label); |
629 return (mac_biba_to_string(sb, mac_biba)); |
630} 631 632static int 633mac_biba_parse_element(struct mac_biba_element *element, char *string) 634{ 635 char *compartment, *end, *grade; 636 int value; 637 --- 2095 unchanged lines hidden --- |