From: Christian Brauner Date: Tue, 12 Dec 2017 00:38:40 +0000 (+0100) Subject: tools: block using lxc-execute without config file X-Git-Tag: lxc-2.0.10~486 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40028d983aa59bbc0d3a68e0168ce8fd67a594de;p=thirdparty%2Flxc.git 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: Felix Abecassis Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_execute.c b/src/lxc/tools/lxc_execute.c index f3ffc5f66..473dcb2be 100644 --- a/src/lxc/tools/lxc_execute.c +++ b/src/lxc/tools/lxc_execute.c @@ -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);