Commit e0b6898a by Dwight Engen Committed by Serge Hallyn

use proper config item depending on which lsm is enabled

On a system with AppArmor enabled, if lxc.se_context is configured but lxc.aa_profile is not (because the user just wants to use the default AppArmor profile) lxc was passing the lxc.se_context to be set as the new AppArmor profile. Determine which configuration item to use based on which lsm is enabled. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 72863294
...@@ -488,6 +488,7 @@ static int must_drop_cap_sys_boot(struct lxc_conf *conf) ...@@ -488,6 +488,7 @@ static int must_drop_cap_sys_boot(struct lxc_conf *conf)
static int do_start(void *data) static int do_start(void *data)
{ {
struct lxc_handler *handler = data; struct lxc_handler *handler = data;
const char *lsm_label = NULL;
if (sigprocmask(SIG_SETMASK, &handler->oldmask, NULL)) { if (sigprocmask(SIG_SETMASK, &handler->oldmask, NULL)) {
SYSERROR("failed to set sigprocmask"); SYSERROR("failed to set sigprocmask");
...@@ -557,9 +558,11 @@ static int do_start(void *data) ...@@ -557,9 +558,11 @@ static int do_start(void *data)
return -1; return -1;
/* Set the label to change to when we exec(2) the container's init */ /* Set the label to change to when we exec(2) the container's init */
if (lsm_process_label_set(handler->conf->lsm_aa_profile ? if (!strcmp(lsm_name(), "AppArmor"))
handler->conf->lsm_aa_profile : lsm_label = handler->conf->lsm_aa_profile;
handler->conf->lsm_se_context, 1, 1) < 0) else if (!strcmp(lsm_name(), "SELinux"))
lsm_label = handler->conf->lsm_se_context;
if (lsm_process_label_set(lsm_label, 1, 1) < 0)
goto out_warn_father; goto out_warn_father;
lsm_proc_unmount(handler->conf); lsm_proc_unmount(handler->conf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment