From: Stéphane Graber Date: Wed, 5 Jun 2024 22:40:15 +0000 (-0400) Subject: Remove unused function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5603534a984718ae45981e9d16d5f19bf44ebe06;p=thirdparty%2Flxc.git Remove unused function Signed-off-by: Stéphane Graber --- diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 0b14c05ad..60f2b7000 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -974,101 +974,6 @@ char *on_path(const char *cmd, const char *rootfs) 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 diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 956ea2a5e..923ce8596 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -141,7 +141,6 @@ __hidden extern bool is_shared_mountpoint(const char *path); __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,