2 * security/tomoyo/load_policy.c
4 * Copyright (C) 2005-2011 NTT DATA CORPORATION
9 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
12 * Path to the policy loader. (default = CONFIG_SECURITY_TOMOYO_POLICY_LOADER)
14 static const char *tomoyo_loader
;
17 * tomoyo_loader_setup - Set policy loader.
19 * @str: Program to use as a policy loader (e.g. /sbin/tomoyo-init ).
23 static int __init
tomoyo_loader_setup(char *str
)
29 __setup("TOMOYO_loader=", tomoyo_loader_setup
);
32 * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists.
34 * Returns true if /sbin/tomoyo-init exists, false otherwise.
36 static bool tomoyo_policy_loader_exists(void)
40 tomoyo_loader
= CONFIG_SECURITY_TOMOYO_POLICY_LOADER
;
41 if (kern_path(tomoyo_loader
, LOOKUP_FOLLOW
, &path
)) {
42 printk(KERN_INFO
"Not activating Mandatory Access Control "
43 "as %s does not exist.\n", tomoyo_loader
);
51 * Path to the trigger. (default = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER)
53 static const char *tomoyo_trigger
;
56 * tomoyo_trigger_setup - Set trigger for activation.
58 * @str: Program to use as an activation trigger (e.g. /sbin/init ).
62 static int __init
tomoyo_trigger_setup(char *str
)
68 __setup("TOMOYO_trigger=", tomoyo_trigger_setup
);
71 * tomoyo_load_policy - Run external policy loader to load policy.
73 * @filename: The program about to start.
75 * This function checks whether @filename is /sbin/init , and if so
76 * invoke /sbin/tomoyo-init and wait for the termination of /sbin/tomoyo-init
77 * and then continues invocation of /sbin/init.
78 * /sbin/tomoyo-init reads policy files in /etc/tomoyo/ directory and
79 * writes to /sys/kernel/security/tomoyo/ interfaces.
83 void tomoyo_load_policy(const char *filename
)
89 if (tomoyo_policy_loaded
|| done
)
92 tomoyo_trigger
= CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER
;
93 if (strcmp(filename
, tomoyo_trigger
))
95 if (!tomoyo_policy_loader_exists())
98 printk(KERN_INFO
"Calling %s to load policy. Please wait.\n",
100 argv
[0] = (char *) tomoyo_loader
;
103 envp
[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
105 call_usermodehelper(argv
[0], argv
, envp
, UMH_WAIT_PROC
);
106 tomoyo_check_profile();