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 <fabecassis@nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2017-12-12 01:38:40 +01:00
parent f449521ce6
commit 19bfbf6e94
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -163,6 +163,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);
}
if (my_args.argc == 0) {
if (!set_argv(c->lxc_conf, &my_args)) {
fprintf(stderr, "missing command to execute!\n");