0001
0002
0003
0004
0005
0006
0007
0008 #include "common.h"
0009
0010 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
0011
0012
0013
0014
0015 static const char *tomoyo_loader;
0016
0017
0018
0019
0020
0021
0022
0023
0024 static int __init tomoyo_loader_setup(char *str)
0025 {
0026 tomoyo_loader = str;
0027 return 1;
0028 }
0029
0030 __setup("TOMOYO_loader=", tomoyo_loader_setup);
0031
0032
0033
0034
0035
0036
0037 static bool tomoyo_policy_loader_exists(void)
0038 {
0039 struct path path;
0040
0041 if (!tomoyo_loader)
0042 tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
0043 if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
0044 pr_info("Not activating Mandatory Access Control as %s does not exist.\n",
0045 tomoyo_loader);
0046 return false;
0047 }
0048 path_put(&path);
0049 return true;
0050 }
0051
0052
0053
0054
0055 static const char *tomoyo_trigger;
0056
0057
0058
0059
0060
0061
0062
0063
0064 static int __init tomoyo_trigger_setup(char *str)
0065 {
0066 tomoyo_trigger = str;
0067 return 1;
0068 }
0069
0070 __setup("TOMOYO_trigger=", tomoyo_trigger_setup);
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 void tomoyo_load_policy(const char *filename)
0086 {
0087 static bool done;
0088 char *argv[2];
0089 char *envp[3];
0090
0091 if (tomoyo_policy_loaded || done)
0092 return;
0093 if (!tomoyo_trigger)
0094 tomoyo_trigger = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER;
0095 if (strcmp(filename, tomoyo_trigger))
0096 return;
0097 if (!tomoyo_policy_loader_exists())
0098 return;
0099 done = true;
0100 pr_info("Calling %s to load policy. Please wait.\n", tomoyo_loader);
0101 argv[0] = (char *) tomoyo_loader;
0102 argv[1] = NULL;
0103 envp[0] = "HOME=/";
0104 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
0105 envp[2] = NULL;
0106 call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
0107 tomoyo_check_profile();
0108 }
0109
0110 #endif