Commit f97ab3a6 by Christian Brauner

Merge pull request #808 from hallyn/2016-02-07/aa.2

apparmor: don't fail if current aa label is given
parents e8f8436c 374625aa
...@@ -146,16 +146,15 @@ static bool aa_stacking_supported(void) { ...@@ -146,16 +146,15 @@ static bool aa_stacking_supported(void) {
return false; return false;
} }
/* are we in a confined container? */ static bool aa_needs_transition(char *curlabel)
static bool in_aa_confined_container(void) { {
char *p = apparmor_process_label_get(getpid()); if (!curlabel)
bool ret = false; return false;
if (p && strcmp(p, "/usr/bin/lxc-start") != 0 && strcmp(p, "unconfined") != 0) { if (strcmp(curlabel, "unconfined") == 0)
INFO("Already apparmor-confined under %s", p); return false;
ret = true; if (strcmp(curlabel, "/usr/bin/lxc-start") == 0)
} return false;
free(p); return true;
return ret;
} }
/* /*
...@@ -174,6 +173,7 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf ...@@ -174,6 +173,7 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf
int use_default, int on_exec) int use_default, int on_exec)
{ {
const char *label = inlabel ? inlabel : conf->lsm_aa_profile; const char *label = inlabel ? inlabel : conf->lsm_aa_profile;
char *curlabel;
if (!aa_enabled) if (!aa_enabled)
return 0; return 0;
...@@ -184,17 +184,22 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf ...@@ -184,17 +184,22 @@ static int apparmor_process_label_set(const char *inlabel, struct lxc_conf *conf
return 0; return 0;
} }
/* curlabel = apparmor_process_label_get(getpid());
* If we are already confined and no profile was requested,
* then default to unchanged if (!aa_stacking_supported() && aa_needs_transition(curlabel)) {
*/ // we're already confined, and stacking isn't supported
if (in_aa_confined_container() && !aa_stacking_supported()) {
if (label) { if (!label || strcmp(curlabel, label) == 0) {
ERROR("already apparmor confined, but new label requested."); // no change requested
return -1; free(curlabel);
return 0;
} }
return 0;
ERROR("already apparmor confined, but new label requested.");
free(curlabel);
return -1;
} }
free(curlabel);
if (!label) { if (!label) {
if (use_default) if (use_default)
......
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