| 2452 | } |
| 2453 | |
| 2454 | static int |
| 2455 | mls_vnode_associate_extattr(struct mount *mp, struct label *mplabel, |
| 2456 | struct vnode *vp, struct label *vplabel) |
| 2457 | { |
| 2458 | struct mac_mls mm_temp, *source, *dest; |
| 2459 | int buflen, error; |
| 2460 | |
| 2461 | source = SLOT(mplabel); |
| 2462 | dest = SLOT(vplabel); |
| 2463 | |
| 2464 | buflen = sizeof(mm_temp); |
| 2465 | bzero(&mm_temp, buflen); |
| 2466 | |
| 2467 | error = vn_extattr_get(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE, |
| 2468 | MAC_MLS_EXTATTR_NAME, &buflen, (char *) &mm_temp, curthread); |
| 2469 | if (error == ENOATTR || error == EOPNOTSUPP) { |
| 2470 | /* Fall back to the mntlabel. */ |
| 2471 | mls_copy_effective(source, dest); |
| 2472 | return (0); |
| 2473 | } else if (error) |
| 2474 | return (error); |
| 2475 | |
| 2476 | if (buflen != sizeof(mm_temp)) { |
| 2477 | printf("mls_vnode_associate_extattr: bad size %d\n", buflen); |
| 2478 | return (EPERM); |
| 2479 | } |
| 2480 | if (mls_valid(&mm_temp) != 0) { |
| 2481 | printf("mls_vnode_associate_extattr: invalid\n"); |
| 2482 | return (EPERM); |
| 2483 | } |
| 2484 | if ((mm_temp.mm_flags & MAC_MLS_FLAGS_BOTH) != |
| 2485 | MAC_MLS_FLAG_EFFECTIVE) { |
| 2486 | printf("mls_associated_vnode_extattr: not effective\n"); |
| 2487 | return (EPERM); |
| 2488 | } |
| 2489 | |
| 2490 | mls_copy_effective(&mm_temp, dest); |
| 2491 | return (0); |
| 2492 | } |
| 2493 | |
| 2494 | static void |
| 2495 | mls_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, |
nothing calls this directly
no test coverage detected