/etc/mac.conf is implicitly read and parsed when the MAC configuration

is accessed for the first time as a result of an application looking
up label configuration information.  Previously, the check and read
were kicked off by mac_prepare_(typename)() functions; since
mac_prepare_type() may now be directly employed by a user process,
push the check and initialization into that function.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
This commit is contained in:
Robert Watson 2003-11-15 03:34:58 +00:00
parent 3bfa61d221
commit 6e07ce26f9

View File

@ -358,9 +358,15 @@ int
mac_prepare_type(struct mac **mac, const char *name)
{
struct label_default *ld;
int error;
error = mac_maybe_init_internal();
if (error != 0)
return (error);
for (ld = LIST_FIRST(&label_default_head); ld != NULL;
ld = LIST_NEXT(ld, ld_entries)) {
printf("%s\n", ld->ld_name);
if (strcmp(name, ld->ld_name) == 0)
return (mac_prepare(mac, ld->ld_labels));
}
@ -372,11 +378,6 @@ mac_prepare_type(struct mac **mac, const char *name)
int
mac_prepare_ifnet_label(struct mac **mac)
{
int error;
error = mac_maybe_init_internal();
if (error != 0)
return (error);
return (mac_prepare_type(mac, "ifnet"));
}
@ -384,11 +385,6 @@ mac_prepare_ifnet_label(struct mac **mac)
int
mac_prepare_file_label(struct mac **mac)
{
int error;
error = mac_maybe_init_internal();
if (error != 0)
return (error);
return (mac_prepare_type(mac, "file"));
}
@ -396,11 +392,6 @@ mac_prepare_file_label(struct mac **mac)
int
mac_prepare_packet_label(struct mac **mac)
{
int error;
error = mac_maybe_init_internal();
if (error != 0)
return (error);
return (mac_prepare_type(mac, "packet"));
}
@ -408,11 +399,6 @@ mac_prepare_packet_label(struct mac **mac)
int
mac_prepare_process_label(struct mac **mac)
{
int error;
error = mac_maybe_init_internal();
if (error != 0)
return (error);
return (mac_prepare_type(mac, "process"));
}