| 500 | } |
| 501 | |
| 502 | static int |
| 503 | kern___mac_set_path(struct thread *td, const char *path_p, struct mac *mac_p, |
| 504 | int follow) |
| 505 | { |
| 506 | struct label *intlabel; |
| 507 | struct nameidata nd; |
| 508 | struct mount *mp; |
| 509 | struct mac mac; |
| 510 | char *buffer; |
| 511 | int error; |
| 512 | |
| 513 | if (!(mac_labeled & MPC_OBJECT_VNODE)) |
| 514 | return (EINVAL); |
| 515 | |
| 516 | error = copyin(mac_p, &mac, sizeof(mac)); |
| 517 | if (error) |
| 518 | return (error); |
| 519 | |
| 520 | error = mac_check_structmac_consistent(&mac); |
| 521 | if (error) |
| 522 | return (error); |
| 523 | |
| 524 | buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK); |
| 525 | error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL); |
| 526 | if (error) { |
| 527 | free(buffer, M_MACTEMP); |
| 528 | return (error); |
| 529 | } |
| 530 | |
| 531 | intlabel = mac_vnode_label_alloc(); |
| 532 | error = mac_vnode_internalize_label(intlabel, buffer); |
| 533 | free(buffer, M_MACTEMP); |
| 534 | if (error) |
| 535 | goto out; |
| 536 | |
| 537 | NDINIT(&nd, LOOKUP, LOCKLEAF | follow, UIO_USERSPACE, path_p, td); |
| 538 | error = namei(&nd); |
| 539 | if (error == 0) { |
| 540 | error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH); |
| 541 | if (error == 0) { |
| 542 | error = vn_setlabel(nd.ni_vp, intlabel, |
| 543 | td->td_ucred); |
| 544 | vn_finished_write(mp); |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | NDFREE(&nd, 0); |
| 549 | out: |
| 550 | mac_vnode_label_free(intlabel); |
| 551 | return (error); |
| 552 | } |
| 553 | |
| 554 | int |
| 555 | sys_mac_syscall(struct thread *td, struct mac_syscall_args *uap) |
no test coverage detected