tools: block using lxc-execute without config file

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 https://github.com/lxc/go-lxc/pull/96#discussion_r155075560 . Closes #2023. Reported-by: 's avatarFelix Abecassis <fabecassis@nvidia.com> Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent e0d498f1
...@@ -151,6 +151,12 @@ int main(int argc, char *argv[]) ...@@ -151,6 +151,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); ret = lxc_config_define_load(&defines, c->lxc_conf);
if (ret) { if (ret) {
lxc_container_put(c); lxc_container_put(c);
......
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