2 * security/tomoyo/load_policy.c
4 * Policy loader launcher for TOMOYO.
6 * Copyright (C) 2005-2010 NTT DATA CORPORATION
11 /* path to policy loader */
12 static const char *tomoyo_loader
= "/sbin/tomoyo-init";
15 * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists.
17 * Returns true if /sbin/tomoyo-init exists, false otherwise.
19 static bool tomoyo_policy_loader_exists(void)
22 * Don't activate MAC if the policy loader doesn't exist.
23 * If the initrd includes /sbin/init but real-root-dev has not
24 * mounted on / yet, activating MAC will block the system since
25 * policies are not loaded yet.
26 * Thus, let do_execve() call this function every time.
30 if (kern_path(tomoyo_loader
, LOOKUP_FOLLOW
, &path
)) {
31 printk(KERN_INFO
"Not activating Mandatory Access Control now "
32 "since %s doesn't exist.\n", tomoyo_loader
);
40 * tomoyo_load_policy - Run external policy loader to load policy.
42 * @filename: The program about to start.
44 * This function checks whether @filename is /sbin/init , and if so
45 * invoke /sbin/tomoyo-init and wait for the termination of /sbin/tomoyo-init
46 * and then continues invocation of /sbin/init.
47 * /sbin/tomoyo-init reads policy files in /etc/tomoyo/ directory and
48 * writes to /sys/kernel/security/tomoyo/ interfaces.
52 void tomoyo_load_policy(const char *filename
)
57 if (tomoyo_policy_loaded
)
60 * Check filename is /sbin/init or /sbin/tomoyo-start.
61 * /sbin/tomoyo-start is a dummy filename in case where /sbin/init can't
63 * You can create /sbin/tomoyo-start by
64 * "ln -s /bin/true /sbin/tomoyo-start".
66 if (strcmp(filename
, "/sbin/init") &&
67 strcmp(filename
, "/sbin/tomoyo-start"))
69 if (!tomoyo_policy_loader_exists())
72 printk(KERN_INFO
"Calling %s to load policy. Please wait.\n",
74 argv
[0] = (char *) tomoyo_loader
;
77 envp
[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
79 call_usermodehelper(argv
[0], argv
, envp
, 1);
80 tomoyo_check_profile();