Commit bd7b4e28 by Stéphane Graber

Fix seccomp profile on attach of undefined container

parent d86eb75c
...@@ -661,6 +661,7 @@ static bool fetch_seccomp(const char *name, const char *lxcpath, ...@@ -661,6 +661,7 @@ static bool fetch_seccomp(const char *name, const char *lxcpath,
struct lxc_proc_context_info *i, lxc_attach_options_t *options) struct lxc_proc_context_info *i, lxc_attach_options_t *options)
{ {
struct lxc_container *c; struct lxc_container *c;
char *path;
if (!(options->namespaces & CLONE_NEWNS) || !(options->attach_flags & LXC_ATTACH_LSM)) if (!(options->namespaces & CLONE_NEWNS) || !(options->attach_flags & LXC_ATTACH_LSM))
return true; return true;
...@@ -669,8 +670,26 @@ static bool fetch_seccomp(const char *name, const char *lxcpath, ...@@ -669,8 +670,26 @@ static bool fetch_seccomp(const char *name, const char *lxcpath,
if (!c) if (!c)
return false; return false;
i->container = c; i->container = c;
if (!c->lxc_conf)
/* Initialize an empty lxc_conf */
if (!c->set_config_item(c, "lxc.seccomp", "")) {
return false; return false;
}
/* Fetch the current profile path over the cmd interface */
path = c->get_running_config_item(c, "lxc.seccomp");
if (!path) {
return true;
}
/* Copy the value into the new lxc_conf */
if (!c->set_config_item(c, "lxc.seccomp", path)) {
free(path);
return false;
}
free(path);
/* Attempt to parse the resulting config */
if (lxc_read_seccomp_config(c->lxc_conf) < 0) { if (lxc_read_seccomp_config(c->lxc_conf) < 0) {
ERROR("Error reading seccomp policy"); ERROR("Error reading seccomp policy");
return false; return false;
......
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