return NULL;
}
-/* historically lxc-init has been under /usr/lib/lxc and under
- * /usr/lib/$ARCH/lxc. It now lives as $prefix/sbin/init.lxc.
- */
-char *choose_init(const char *rootfs)
-{
- char *retv = NULL;
- const char *empty = "",
- *tmp;
- int ret, env_set = 0;
-
- if (!getenv("PATH")) {
- if (setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 0))
- SYSERROR("Failed to setenv");
-
- env_set = 1;
- }
-
- retv = on_path("init.lxc", rootfs);
-
- if (env_set)
- if (unsetenv("PATH"))
- SYSERROR("Failed to unsetenv");
-
- if (retv)
- return retv;
-
- retv = malloc(PATH_MAX);
- if (!retv)
- return NULL;
-
- if (rootfs)
- tmp = rootfs;
- else
- tmp = empty;
-
- ret = strnprintf(retv, PATH_MAX, "%s/%s/%s", tmp, SBINDIR, "/init.lxc");
- if (ret < 0) {
- ERROR("The name of path is too long");
- goto out1;
- }
-
- if (access(retv, X_OK) == 0)
- return retv;
-
- ret = strnprintf(retv, PATH_MAX, "%s/%s/%s", tmp, LXCINITDIR, "/lxc/lxc-init");
- if (ret < 0) {
- ERROR("The name of path is too long");
- goto out1;
- }
-
- if (access(retv, X_OK) == 0)
- return retv;
-
- ret = strnprintf(retv, PATH_MAX, "%s/usr/lib/lxc/lxc-init", tmp);
- if (ret < 0) {
- ERROR("The name of path is too long");
- goto out1;
- }
-
- if (access(retv, X_OK) == 0)
- return retv;
-
- ret = strnprintf(retv, PATH_MAX, "%s/sbin/lxc-init", tmp);
- if (ret < 0) {
- ERROR("The name of path is too long");
- goto out1;
- }
-
- if (access(retv, X_OK) == 0)
- return retv;
-
- /*
- * Last resort, look for the statically compiled init.lxc which we
- * hopefully bind-mounted in.
- * If we are called during container setup, and we get to this point,
- * then the init.lxc.static from the host will need to be bind-mounted
- * in. So we return NULL here to indicate that.
- */
- if (rootfs)
- goto out1;
-
- ret = strnprintf(retv, PATH_MAX, "/init.lxc.static");
- if (ret < 0) {
- WARN("Nonsense - name /lxc.init.static too long");
- goto out1;
- }
-
- if (access(retv, X_OK) == 0)
- return retv;
-
-out1:
- free(retv);
- return NULL;
-}
-
/*
* Given the '-t' template option to lxc-create, figure out what to
* do. If the template is a full executable path, use that. If it
__hidden extern int detect_shared_rootfs(void);
__hidden extern bool detect_ramfs_rootfs(void);
__hidden extern char *on_path(const char *cmd, const char *rootfs);
-__hidden extern char *choose_init(const char *rootfs);
__hidden extern bool switch_to_ns(pid_t pid, const char *ns);
__hidden extern char *get_template_path(const char *t);
__hidden extern int safe_mount(const char *src, const char *dest, const char *fstype,