* mls_to_string() converts an MLS label to a string, and places the results * in the passed sbuf. It returns 0 on success, or EINVAL if there isn't * room in the sbuf. Note: the sbuf will be modified even in a failure case, * so the caller may need to revert the sbuf by restoring the offset if * that's undesired. */
| 551 | * that's undesired. |
| 552 | */ |
| 553 | static int |
| 554 | mls_to_string(struct sbuf *sb, struct mac_mls *mm) |
| 555 | { |
| 556 | |
| 557 | if (mm->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { |
| 558 | if (mls_element_to_string(sb, &mm->mm_effective) == -1) |
| 559 | return (EINVAL); |
| 560 | } |
| 561 | |
| 562 | if (mm->mm_flags & MAC_MLS_FLAG_RANGE) { |
| 563 | if (sbuf_putc(sb, '(') == -1) |
| 564 | return (EINVAL); |
| 565 | |
| 566 | if (mls_element_to_string(sb, &mm->mm_rangelow) == -1) |
| 567 | return (EINVAL); |
| 568 | |
| 569 | if (sbuf_putc(sb, '-') == -1) |
| 570 | return (EINVAL); |
| 571 | |
| 572 | if (mls_element_to_string(sb, &mm->mm_rangehigh) == -1) |
| 573 | return (EINVAL); |
| 574 | |
| 575 | if (sbuf_putc(sb, ')') == -1) |
| 576 | return (EINVAL); |
| 577 | } |
| 578 | |
| 579 | return (0); |
| 580 | } |
| 581 | |
| 582 | static int |
| 583 | mls_externalize_label(struct label *label, char *element_name, |
no test coverage detected