* Allow MAC policy modules to register during boot, etc. */
| 643 | * Allow MAC policy modules to register during boot, etc. |
| 644 | */ |
| 645 | int |
| 646 | mac_policy_modevent(module_t mod, int type, void *data) |
| 647 | { |
| 648 | struct mac_policy_conf *mpc; |
| 649 | int error; |
| 650 | |
| 651 | error = 0; |
| 652 | mpc = (struct mac_policy_conf *) data; |
| 653 | |
| 654 | #ifdef MAC_STATIC |
| 655 | if (mac_late) { |
| 656 | printf("mac_policy_modevent: MAC_STATIC and late\n"); |
| 657 | return (EBUSY); |
| 658 | } |
| 659 | #endif |
| 660 | |
| 661 | SDT_PROBE2(mac, , policy, modevent, type, mpc); |
| 662 | switch (type) { |
| 663 | case MOD_LOAD: |
| 664 | if (mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_NOTLATE && |
| 665 | mac_late) { |
| 666 | printf("mac_policy_modevent: can't load %s policy " |
| 667 | "after booting\n", mpc->mpc_name); |
| 668 | error = EBUSY; |
| 669 | break; |
| 670 | } |
| 671 | error = mac_policy_register(mpc); |
| 672 | break; |
| 673 | case MOD_UNLOAD: |
| 674 | /* Don't unregister the module if it was never registered. */ |
| 675 | if ((mpc->mpc_runtime_flags & MPC_RUNTIME_FLAG_REGISTERED) |
| 676 | != 0) |
| 677 | error = mac_policy_unregister(mpc); |
| 678 | else |
| 679 | error = 0; |
| 680 | break; |
| 681 | default: |
| 682 | error = EOPNOTSUPP; |
| 683 | break; |
| 684 | } |
| 685 | |
| 686 | return (error); |
| 687 | } |
| 688 | |
| 689 | /* |
| 690 | * Define an error value precedence, and given two arguments, selects the |
nothing calls this directly
no test coverage detected