[OpenWrt-Devel] [PATCH procd v2 11/17] ujail: add init_library_search()
Etienne CHAMPETIER
champetier.etienne at gmail.com
Wed Nov 25 12:54:44 EST 2015
move all libraries search initialisation stuff
into elf.c / init_library_search()
for now we don't handle musl specific files
Signed-off-by: Etienne CHAMPETIER <champetier.etienne at gmail.com>
---
jail/elf.c | 13 +++++++++++--
jail/elf.h | 3 +--
jail/jail.c | 6 +-----
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/jail/elf.c b/jail/elf.c
index 2acac71..c3a392c 100644
--- a/jail/elf.c
+++ b/jail/elf.c
@@ -32,7 +32,7 @@
struct avl_tree libraries;
static LIST_HEAD(library_paths);
-void alloc_library_path(const char *path)
+static void alloc_library_path(const char *path)
{
struct stat s;
if (stat(path, &s))
@@ -311,7 +311,7 @@ err_out:
return ret;
}
-void load_ldso_conf(const char *conf)
+static void load_ldso_conf(const char *conf)
{
FILE* fp = fopen(conf, "r");
char line[PATH_MAX];
@@ -356,3 +356,12 @@ void load_ldso_conf(const char *conf)
fclose(fp);
}
+
+void init_library_search(void)
+{
+ avl_init(&libraries, avl_strcmp, false, NULL);
+ alloc_library_path("/lib");
+ alloc_library_path("/lib64");
+ alloc_library_path("/usr/lib");
+ load_ldso_conf("/etc/ld.so.conf");
+}
diff --git a/jail/elf.h b/jail/elf.h
index 6687f3c..bb9c143 100644
--- a/jail/elf.h
+++ b/jail/elf.h
@@ -28,7 +28,6 @@ struct library_path {
extern struct avl_tree libraries;
-void alloc_library_path(const char *path);
int elf_load_deps(const char *library);
const char* find_lib(const char *file);
-void load_ldso_conf(const char *conf);
+void init_library_search(void);
diff --git a/jail/jail.c b/jail/jail.c
index 90aa482..5b24f63 100644
--- a/jail/jail.c
+++ b/jail/jail.c
@@ -154,11 +154,7 @@ static int build_jail_fs()
return -1;
}
- avl_init(&libraries, avl_strcmp, false, NULL);
- alloc_library_path("/lib");
- alloc_library_path("/lib64");
- alloc_library_path("/usr/lib");
- load_ldso_conf("/etc/ld.so.conf");
+ init_library_search();
if (elf_load_deps(*opts.jail_argv)) {
ERROR("failed to load dependencies\n");
--
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list