ujail: add init_library_search()
authorEtienne CHAMPETIER <champetier.etienne@gmail.com>
Fri, 27 Nov 2015 16:27:10 +0000 (16:27 +0000)
committerJohn Crispin <blogic@openwrt.org>
Fri, 27 Nov 2015 16:48:49 +0000 (17:48 +0100)
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@gmail.com>
jail/elf.c
jail/elf.h
jail/jail.c

index 2acac71ae401fbbdd67da4615a94e4480624a733..c3a392c775b71cab2218381abfc9ff63166d25e3 100644 (file)
@@ -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");
+}
index 4ab928d80e7f1a8f62ef75e9ddaca3e72daecd7e..6244e76c1059d4d306e44ec4b9fa70eceec054e3 100644 (file)
@@ -29,9 +29,8 @@ 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);
 
 #endif
index 90aa4823e8357435b6b2ad082e475e022a1b9062..5b24f63165e03dc17058cd43d3176eef19dc9847 100644 (file)
@@ -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");