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_seeotheruids/mac_seeotheruids.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_seeotheruids/mac_seeotheruids.c')
-rw-r--r-- | sys/security/mac_seeotheruids/mac_seeotheruids.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sys/security/mac_seeotheruids/mac_seeotheruids.c b/sys/security/mac_seeotheruids/mac_seeotheruids.c index 8233724..06c95e6 100644 --- a/sys/security/mac_seeotheruids/mac_seeotheruids.c +++ b/sys/security/mac_seeotheruids/mac_seeotheruids.c @@ -160,20 +160,14 @@ mac_seeotheruids_check_socket_visible(struct ucred *cred, struct socket *socket, return (mac_seeotheruids_check(cred, socket->so_cred)); } -static struct mac_policy_op_entry mac_seeotheruids_ops[] = +static struct mac_policy_ops mac_seeotheruids_ops = { - { MAC_CHECK_CRED_VISIBLE, - (macop_t)mac_seeotheruids_check_cred_visible }, - { MAC_CHECK_PROC_DEBUG, - (macop_t)mac_seeotheruids_check_proc_debug }, - { MAC_CHECK_PROC_SCHED, - (macop_t)mac_seeotheruids_check_proc_sched }, - { MAC_CHECK_PROC_SIGNAL, - (macop_t)mac_seeotheruids_check_proc_signal }, - { MAC_CHECK_SOCKET_VISIBLE, - (macop_t)mac_seeotheruids_check_socket_visible }, - { MAC_OP_LAST, NULL } + .mpo_check_cred_visible = mac_seeotheruids_check_cred_visible, + .mpo_check_proc_debug = mac_seeotheruids_check_proc_debug, + .mpo_check_proc_sched = mac_seeotheruids_check_proc_sched, + .mpo_check_proc_signal = mac_seeotheruids_check_proc_signal, + .mpo_check_socket_visible = mac_seeotheruids_check_socket_visible, }; -MAC_POLICY_SET(mac_seeotheruids_ops, trustedbsd_mac_seeotheruids, +MAC_POLICY_SET(&mac_seeotheruids_ops, trustedbsd_mac_seeotheruids, "TrustedBSD MAC/seeotheruids", MPC_LOADTIME_FLAG_UNLOADOK, NULL); |