mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-09 19:29:15 +00:00
container start: check for start hooks in container rootfs
Do so early enough that we can report a meaningful failure. (This should fix https://github.com/lxc/lxc/issues/225) Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
4e31246a25
commit
1c1c70514f
@ -3896,6 +3896,30 @@ int do_rootfs_setup(struct lxc_conf *conf, const char *name, const char *lxcpath
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool verify_start_hooks(struct lxc_conf *conf)
|
||||||
|
{
|
||||||
|
struct lxc_list *it;
|
||||||
|
char path[MAXPATHLEN];
|
||||||
|
lxc_list_for_each(it, &conf->hooks[LXCHOOK_START]) {
|
||||||
|
char *hookname = it->elem;
|
||||||
|
struct stat st;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = snprintf(path, MAXPATHLEN, "%s%s",
|
||||||
|
conf->rootfs.mount, hookname);
|
||||||
|
if (ret < 0 || ret >= MAXPATHLEN)
|
||||||
|
return false;
|
||||||
|
ret = stat(path, &st);
|
||||||
|
if (ret) {
|
||||||
|
SYSERROR("Start hook %s not found in container rootfs",
|
||||||
|
hookname);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int lxc_setup(struct lxc_handler *handler)
|
int lxc_setup(struct lxc_handler *handler)
|
||||||
{
|
{
|
||||||
const char *name = handler->name;
|
const char *name = handler->name;
|
||||||
@ -3949,6 +3973,10 @@ int lxc_setup(struct lxc_handler *handler)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure any start hooks are in the rootfs */
|
||||||
|
if (!verify_start_hooks(lxc_conf))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (lxc_conf->is_execute)
|
if (lxc_conf->is_execute)
|
||||||
lxc_execute_bind_init(lxc_conf);
|
lxc_execute_bind_init(lxc_conf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user