| 523 | } |
| 524 | |
| 525 | int |
| 526 | mac_setsockopt_label(struct ucred *cred, struct socket *so, struct mac *mac) |
| 527 | { |
| 528 | struct label *intlabel; |
| 529 | char *buffer; |
| 530 | int error; |
| 531 | |
| 532 | if (!(mac_labeled & MPC_OBJECT_SOCKET)) |
| 533 | return (EINVAL); |
| 534 | |
| 535 | error = mac_check_structmac_consistent(mac); |
| 536 | if (error) |
| 537 | return (error); |
| 538 | |
| 539 | buffer = malloc(mac->m_buflen, M_MACTEMP, M_WAITOK); |
| 540 | error = copyinstr(mac->m_string, buffer, mac->m_buflen, NULL); |
| 541 | if (error) { |
| 542 | free(buffer, M_MACTEMP); |
| 543 | return (error); |
| 544 | } |
| 545 | |
| 546 | intlabel = mac_socket_label_alloc(M_WAITOK); |
| 547 | error = mac_socket_internalize_label(intlabel, buffer); |
| 548 | free(buffer, M_MACTEMP); |
| 549 | if (error) |
| 550 | goto out; |
| 551 | |
| 552 | error = mac_socket_label_set(cred, so, intlabel); |
| 553 | out: |
| 554 | mac_socket_label_free(intlabel); |
| 555 | return (error); |
| 556 | } |
| 557 | |
| 558 | int |
| 559 | mac_getsockopt_label(struct ucred *cred, struct socket *so, struct mac *mac) |
no test coverage detected