Skip to content

Commit

Permalink
tools: block using lxc-execute without config file
Browse files Browse the repository at this point in the history
Moving away from internal symbols we can't do hacks like we currently do in
lxc-start and call internal functions like lxc_conf_init(). This is unsafe
anyway. Instead, we should simply error out if the user didn't give us a
configuration file to use. lxc-start refuses to start in that case already.

Relates to discussion in lxc/go-lxc#96 (comment) .
Closes #2023.

Reported-by: Felix Abecassis <fabecassis@nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Dec 17, 2017
1 parent c192dc0 commit 40028d9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lxc/tools/lxc_execute.c
Expand Up @@ -148,6 +148,12 @@ int main(int argc, char *argv[])
}
}

if (!c->lxc_conf) {
fprintf(stderr, "Executing a container with no configuration file may crash the host\n");
lxc_container_put(c);
exit(EXIT_FAILURE);
}

ret = lxc_config_define_load(&defines, c->lxc_conf);
if (ret) {
lxc_container_put(c);
Expand Down

0 comments on commit 40028d9

Please sign in to comment.