diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-10-30 18:48:51 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-10-30 18:48:51 +0000 |
commit | 122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55 (patch) | |
tree | 7fd5345746ac073cf8b544fe6fd189e7cef54647 /sys/security/mac_bsdextended/mac_bsdextended.c | |
parent | 50b4c8318b1a99c59fad165b4a97fd68de465f73 (diff) | |
download | FreeBSD-src-122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55.zip FreeBSD-src-122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55.tar.gz |
Move to C99 sparse structure initialization for the mac_policy_ops
structure definition, rather than using an operation vector
we translate into the structure. Originally, we used a vector
for two reasons:
(1) We wanted to define the structure sparsely, which wasn't
supported by the C compiler for structures. For a policy
with five entry points, you don't want to have to stick in
a few hundred NULL function pointers.
(2) We thought it would improve ABI compatibility allowing modules
to work with kernels that had a superset of the entry points
defined in the module, even if the kernel had changed its
entry point set.
Both of these no longer apply:
(1) C99 gives us a way to sparsely define a static structure.
(2) The ABI problems existed anyway, due to enumeration numbers,
argument changes, and semantic mismatches. Since the going
rule for FreeBSD is that you really need your modules to
pretty closely match your kernel, it's not worth the
complexity.
This submit eliminates the operation vector, dynamic allocation
of the operation structure, copying of the vector to the
structure, and redoes the vectors in each policy to direct
structure definitions. One enourmous benefit of this change
is that we now get decent type checking on policy entry point
implementation arguments.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/security/mac_bsdextended/mac_bsdextended.c')
-rw-r--r-- | sys/security/mac_bsdextended/mac_bsdextended.c | 83 |
1 files changed, 28 insertions, 55 deletions
diff --git a/sys/security/mac_bsdextended/mac_bsdextended.c b/sys/security/mac_bsdextended/mac_bsdextended.c index 1435bba..b500d13 100644 --- a/sys/security/mac_bsdextended/mac_bsdextended.c +++ b/sys/security/mac_bsdextended/mac_bsdextended.c @@ -718,62 +718,35 @@ mac_bsdextended_check_vnode_stat(struct ucred *active_cred, VSTAT)); } -static struct mac_policy_op_entry mac_bsdextended_ops[] = +static struct mac_policy_ops mac_bsdextended_ops = { - { MAC_DESTROY, - (macop_t)mac_bsdextended_destroy }, - { MAC_INIT, - (macop_t)mac_bsdextended_init }, - { MAC_CHECK_VNODE_ACCESS, - (macop_t)mac_bsdextended_check_vnode_access }, - { MAC_CHECK_VNODE_CHDIR, - (macop_t)mac_bsdextended_check_vnode_chdir }, - { MAC_CHECK_VNODE_CHROOT, - (macop_t)mac_bsdextended_check_vnode_chroot }, - { MAC_CHECK_VNODE_CREATE, - (macop_t)mac_bsdextended_check_create_vnode }, - { MAC_CHECK_VNODE_DELETE, - (macop_t)mac_bsdextended_check_vnode_delete }, - { MAC_CHECK_VNODE_DELETEACL, - (macop_t)mac_bsdextended_check_vnode_deleteacl }, - { MAC_CHECK_VNODE_EXEC, - (macop_t)mac_bsdextended_check_vnode_exec }, - { MAC_CHECK_VNODE_GETACL, - (macop_t)mac_bsdextended_check_vnode_getacl }, - { MAC_CHECK_VNODE_GETEXTATTR, - (macop_t)mac_bsdextended_check_vnode_getextattr }, - { MAC_CHECK_VNODE_LINK, - (macop_t)mac_bsdextended_check_vnode_link }, - { MAC_CHECK_VNODE_LOOKUP, - (macop_t)mac_bsdextended_check_vnode_lookup }, - { MAC_CHECK_VNODE_OPEN, - (macop_t)mac_bsdextended_check_vnode_open }, - { MAC_CHECK_VNODE_READDIR, - (macop_t)mac_bsdextended_check_vnode_readdir }, - { MAC_CHECK_VNODE_READLINK, - (macop_t)mac_bsdextended_check_vnode_readdlink }, - { MAC_CHECK_VNODE_RENAME_FROM, - (macop_t)mac_bsdextended_check_vnode_rename_from }, - { MAC_CHECK_VNODE_RENAME_TO, - (macop_t)mac_bsdextended_check_vnode_rename_to }, - { MAC_CHECK_VNODE_REVOKE, - (macop_t)mac_bsdextended_check_vnode_revoke }, - { MAC_CHECK_VNODE_SETACL, - (macop_t)mac_bsdextended_check_setacl_vnode }, - { MAC_CHECK_VNODE_SETEXTATTR, - (macop_t)mac_bsdextended_check_vnode_setextattr }, - { MAC_CHECK_VNODE_SETFLAGS, - (macop_t)mac_bsdextended_check_vnode_setflags }, - { MAC_CHECK_VNODE_SETMODE, - (macop_t)mac_bsdextended_check_vnode_setmode }, - { MAC_CHECK_VNODE_SETOWNER, - (macop_t)mac_bsdextended_check_vnode_setowner }, - { MAC_CHECK_VNODE_SETUTIMES, - (macop_t)mac_bsdextended_check_vnode_setutimes }, - { MAC_CHECK_VNODE_STAT, - (macop_t)mac_bsdextended_check_vnode_stat }, - { MAC_OP_LAST, NULL } + .mpo_destroy = mac_bsdextended_destroy, + .mpo_init = mac_bsdextended_init, + .mpo_check_vnode_access = mac_bsdextended_check_vnode_access, + .mpo_check_vnode_chdir = mac_bsdextended_check_vnode_chdir, + .mpo_check_vnode_chroot = mac_bsdextended_check_vnode_chroot, + .mpo_check_vnode_create = mac_bsdextended_check_create_vnode, + .mpo_check_vnode_delete = mac_bsdextended_check_vnode_delete, + .mpo_check_vnode_deleteacl = mac_bsdextended_check_vnode_deleteacl, + .mpo_check_vnode_exec = mac_bsdextended_check_vnode_exec, + .mpo_check_vnode_getacl = mac_bsdextended_check_vnode_getacl, + .mpo_check_vnode_getextattr = mac_bsdextended_check_vnode_getextattr, + .mpo_check_vnode_link = mac_bsdextended_check_vnode_link, + .mpo_check_vnode_lookup = mac_bsdextended_check_vnode_lookup, + .mpo_check_vnode_open = mac_bsdextended_check_vnode_open, + .mpo_check_vnode_readdir = mac_bsdextended_check_vnode_readdir, + .mpo_check_vnode_readlink = mac_bsdextended_check_vnode_readdlink, + .mpo_check_vnode_rename_from = mac_bsdextended_check_vnode_rename_from, + .mpo_check_vnode_rename_to = mac_bsdextended_check_vnode_rename_to, + .mpo_check_vnode_revoke = mac_bsdextended_check_vnode_revoke, + .mpo_check_vnode_setacl = mac_bsdextended_check_setacl_vnode, + .mpo_check_vnode_setextattr = mac_bsdextended_check_vnode_setextattr, + .mpo_check_vnode_setflags = mac_bsdextended_check_vnode_setflags, + .mpo_check_vnode_setmode = mac_bsdextended_check_vnode_setmode, + .mpo_check_vnode_setowner = mac_bsdextended_check_vnode_setowner, + .mpo_check_vnode_setutimes = mac_bsdextended_check_vnode_setutimes, + .mpo_check_vnode_stat = mac_bsdextended_check_vnode_stat, }; -MAC_POLICY_SET(mac_bsdextended_ops, trustedbsd_mac_bsdextended, +MAC_POLICY_SET(&mac_bsdextended_ops, trustedbsd_mac_bsdextended, "TrustedBSD MAC/BSD Extended", MPC_LOADTIME_FLAG_UNLOADOK, NULL); |