2 * security/tomoyo/load_policy.c
4 * Policy loader launcher for TOMOYO.
6 * Copyright (C) 2005-2010 NTT DATA CORPORATION
11 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
14 * Path to the policy loader. (default = CONFIG_SECURITY_TOMOYO_POLICY_LOADER)
16 static const char *tomoyo_loader;
19 * tomoyo_loader_setup - Set policy loader.
21 * @str: Program to use as a policy loader (e.g. /sbin/tomoyo-init ).
25 static int __init tomoyo_loader_setup(char *str)
31 __setup("TOMOYO_loader=", tomoyo_loader_setup);
34 * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists.
36 * Returns true if /sbin/tomoyo-init exists, false otherwise.
38 static bool tomoyo_policy_loader_exists(void)
42 tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
43 if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
44 printk(KERN_INFO "Not activating Mandatory Access Control "
45 "as %s does not exist.\n", tomoyo_loader);
53 * Path to the trigger. (default = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER)
55 static const char *tomoyo_trigger;
58 * tomoyo_trigger_setup - Set trigger for activation.
60 * @str: Program to use as an activation trigger (e.g. /sbin/init ).
64 static int __init tomoyo_trigger_setup(char *str)
70 __setup("TOMOYO_trigger=", tomoyo_trigger_setup);
73 * tomoyo_load_policy - Run external policy loader to load policy.
75 * @filename: The program about to start.
77 * This function checks whether @filename is /sbin/init , and if so
78 * invoke /sbin/tomoyo-init and wait for the termination of /sbin/tomoyo-init
79 * and then continues invocation of /sbin/init.
80 * /sbin/tomoyo-init reads policy files in /etc/tomoyo/ directory and
81 * writes to /sys/kernel/security/tomoyo/ interfaces.
85 void tomoyo_load_policy(const char *filename)
91 if (tomoyo_policy_loaded || done)
94 tomoyo_trigger = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER;
95 if (strcmp(filename, tomoyo_trigger))
97 if (!tomoyo_policy_loader_exists())
100 printk(KERN_INFO "Calling %s to load policy. Please wait.\n",
102 argv[0] = (char *) tomoyo_loader;
105 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
107 call_usermodehelper(argv[0], argv, envp, 1);
108 tomoyo_check_profile();