From 4df60d1cacdeb2cac619f84e0033643c19962c0c Mon Sep 17 00:00:00 2001 From: "Matthew N. Dodd" Date: Sat, 31 May 2003 14:45:11 +0000 Subject: [PATCH] Use the environment variable LD_LIBMAP_DISABLE to disable libmap.conf(5) functionality. --- libexec/rtld-elf/rtld.1 | 3 +++ libexec/rtld-elf/rtld.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1 index 3daad6be998..5ba43e02a82 100644 --- a/libexec/rtld-elf/rtld.1 +++ b/libexec/rtld-elf/rtld.1 @@ -83,6 +83,9 @@ recognizes a number of environment variables that can be used to modify its behaviour as follows: .Pp .Bl -tag -width ".Ev LD_LIBRARY_PATH" +.It Ev LD_LIBMAP_DISABLE +If set disables the use of +.Xr libmap.conf 5 . .It Ev LD_LIBRARY_PATH A colon separated list of directories, overriding the default search path for shared libraries. diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 01a1a338814..9bbd5d4d92b 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -134,6 +134,7 @@ void r_debug_state(struct r_debug*, struct link_map*); */ static char *error_message; /* Message for dlerror(), or NULL */ struct r_debug r_debug; /* for GDB; */ +static bool libmap_disable; /* Disable libmap */ static bool trust; /* False for setuid and setgid programs */ static char *ld_bind_now; /* Environment variable for immediate binding */ static char *ld_debug; /* Environment variable for debugging */ @@ -263,6 +264,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) trust = geteuid() == getuid() && getegid() == getgid(); + libmap_disable = getenv("LD_LIBMAP_DISABLE") != NULL; + ld_bind_now = getenv("LD_BIND_NOW"); if (trust) { ld_debug = getenv("LD_DEBUG"); @@ -339,7 +342,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) sym_zero.st_shndx = SHN_UNDEF; #ifdef WITH_LIBMAP - lm_init(); + if (!libmap_disable) + lm_init(); #endif dbg("loading LD_PRELOAD libraries"); @@ -795,7 +799,7 @@ find_library(const char *xname, const Obj_Entry *refobj) } #ifdef WITH_LIBMAP - if ((name = lm_find(refobj->path, xname)) == NULL) + if (libmap_disable || (name = lm_find(refobj->path, xname)) == NULL) #endif name = (char *)xname; @@ -1434,7 +1438,8 @@ rtld_exit(void) objlist_call_fini(&list_fini); /* No need to remove the items from the list, since we are exiting. */ #ifdef WITH_LIBMAP - lm_fini(); + if (!libmap_disable) + lm_fini(); #endif }