1
2
3
4
5
6
7
8#include "common.h"
9
10#ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
11
12
13
14
15static const char *tomoyo_loader;
16
17
18
19
20
21
22
23
24static int __init tomoyo_loader_setup(char *str)
25{
26 tomoyo_loader = str;
27 return 0;
28}
29
30__setup("TOMOYO_loader=", tomoyo_loader_setup);
31
32
33
34
35
36
37static bool tomoyo_policy_loader_exists(void)
38{
39 struct path path;
40 if (!tomoyo_loader)
41 tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
42 if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
43 printk(KERN_INFO "Not activating Mandatory Access Control "
44 "as %s does not exist.\n", tomoyo_loader);
45 return false;
46 }
47 path_put(&path);
48 return true;
49}
50
51
52
53
54static const char *tomoyo_trigger;
55
56
57
58
59
60
61
62
63static int __init tomoyo_trigger_setup(char *str)
64{
65 tomoyo_trigger = str;
66 return 0;
67}
68
69__setup("TOMOYO_trigger=", tomoyo_trigger_setup);
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84void tomoyo_load_policy(const char *filename)
85{
86 static bool done;
87 char *argv[2];
88 char *envp[3];
89
90 if (tomoyo_policy_loaded || done)
91 return;
92 if (!tomoyo_trigger)
93 tomoyo_trigger = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER;
94 if (strcmp(filename, tomoyo_trigger))
95 return;
96 if (!tomoyo_policy_loader_exists())
97 return;
98 done = true;
99 printk(KERN_INFO "Calling %s to load policy. Please wait.\n",
100 tomoyo_loader);
101 argv[0] = (char *) tomoyo_loader;
102 argv[1] = NULL;
103 envp[0] = "HOME=/";
104 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
105 envp[2] = NULL;
106 call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
107 tomoyo_check_profile();
108}
109
110#endif
111