| 333 | } |
| 334 | |
| 335 | static int |
| 336 | kern___mac_get_path(struct thread *td, const char *path_p, struct mac *mac_p, |
| 337 | int follow) |
| 338 | { |
| 339 | char *elements, *buffer; |
| 340 | struct nameidata nd; |
| 341 | struct label *intlabel; |
| 342 | struct mac mac; |
| 343 | int error; |
| 344 | |
| 345 | if (!(mac_labeled & MPC_OBJECT_VNODE)) |
| 346 | return (EINVAL); |
| 347 | |
| 348 | error = copyin(mac_p, &mac, sizeof(mac)); |
| 349 | if (error) |
| 350 | return (error); |
| 351 | |
| 352 | error = mac_check_structmac_consistent(&mac); |
| 353 | if (error) |
| 354 | return (error); |
| 355 | |
| 356 | elements = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK); |
| 357 | error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL); |
| 358 | if (error) { |
| 359 | free(elements, M_MACTEMP); |
| 360 | return (error); |
| 361 | } |
| 362 | |
| 363 | buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO); |
| 364 | NDINIT(&nd, LOOKUP, LOCKLEAF | follow, UIO_USERSPACE, path_p, td); |
| 365 | error = namei(&nd); |
| 366 | if (error) |
| 367 | goto out; |
| 368 | |
| 369 | intlabel = mac_vnode_label_alloc(); |
| 370 | mac_vnode_copy_label(nd.ni_vp->v_label, intlabel); |
| 371 | error = mac_vnode_externalize_label(intlabel, elements, buffer, |
| 372 | mac.m_buflen); |
| 373 | NDFREE(&nd, 0); |
| 374 | mac_vnode_label_free(intlabel); |
| 375 | |
| 376 | if (error == 0) |
| 377 | error = copyout(buffer, mac.m_string, strlen(buffer)+1); |
| 378 | |
| 379 | out: |
| 380 | free(buffer, M_MACTEMP); |
| 381 | free(elements, M_MACTEMP); |
| 382 | |
| 383 | return (error); |
| 384 | } |
| 385 | |
| 386 | int |
| 387 | sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap) |
no test coverage detected