]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: block using lxc-execute without config file
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 12 Dec 2017 00:38:40 +0000 (01:38 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 12:34:32 +0000 (13:34 +0100)
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 <fabecassis@nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/tools/lxc_execute.c

index e439cb9c56ee39d116756c4841dcd4bda888e18a..07aadff0a4a281d0383517bb534ccb96b64f5492 100644 (file)
@@ -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);
        if (ret) {
                lxc_container_put(c);