trigger: reduce indentation level in trigger_event()
[project/procd.git] / jail / elf.c
index 136789e..7c6076a 100644 (file)
@@ -81,7 +81,7 @@ int lib_open(char **fullpath, const char *file)
 
        list_for_each_entry(p, &library_paths, list) {
                snprintf(path, sizeof(path), "%s/%s", p->path, file);
-               fd = open(path, O_RDONLY);
+               fd = open(path, O_RDONLY|O_CLOEXEC);
                if (fd >= 0) {
                        *fullpath = strdup(path);
                        break;
@@ -234,6 +234,7 @@ int elf_load_deps(const char *path, const char *map)
 {
        unsigned int dyn_offset, dyn_size;
        unsigned int load_offset, load_vaddr;
+       unsigned int interp_offset;
 
        if (elf_find_section(map, PT_LOAD, &load_offset, NULL, &load_vaddr)) {
                ERROR("failed to load the .load section from %s\n", path);
@@ -245,6 +246,10 @@ int elf_load_deps(const char *path, const char *map)
                return -1;
        }
 
+       if (elf_find_section(map, PT_INTERP, &interp_offset, NULL, NULL) == 0) {
+               add_path_and_deps(map+interp_offset, 1, -1, 0);
+       }
+
        int clazz = map[EI_CLASS];
 
        if (clazz == ELFCLASS32)