summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-03-23 16:49:00 +0000
committerdelphij <delphij@FreeBSD.org>2009-03-23 16:49:00 +0000
commit63c651080ec8845c46df852316aaabb4848ba4b1 (patch)
tree6a0f47ffd12c3cf50487ad27b0f44039adfca76e /libexec
parent7e0f7398ba9967462bbada5db3f2e4e9de7632aa (diff)
downloadFreeBSD-src-63c651080ec8845c46df852316aaabb4848ba4b1.zip
FreeBSD-src-63c651080ec8845c46df852316aaabb4848ba4b1.tar.gz
Support for a new environment variable, LD_ELF_HINTS_PATH for overriding
the rtld hints file. This environment variable would be unset if the process is considered as tainted with setuid/setgid. This feature gives a convenient way of using a custom set of shared library that is not located in the default location and switch back. Feature requested by: iXsystems Original patch by: John Hixson MFC after: 2 weeks
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.17
-rw-r--r--libexec/rtld-elf/rtld.c11
2 files changed, 15 insertions, 3 deletions
diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1
index 011a693..81f3685 100644
--- a/libexec/rtld-elf/rtld.1
+++ b/libexec/rtld-elf/rtld.1
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 15, 2008
+.Dd March 23, 2009
.Dt RTLD 1
.Os
.Sh NAME
@@ -116,6 +116,11 @@ If set, disables the use of
and
.Ev LD_LIBMAP .
This variable is unset for set-user-ID and set-group-ID programs.
+.It Ev LD_ELF_HINTS_PATH
+This variable will override the default location of
+.Dq hints
+file.
+This variable is unset for set-user-ID and set-group-ID programs.
.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 1477b16..823427a 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -162,6 +162,7 @@ static char *ld_debug; /* Environment variable for debugging */
static char *ld_library_path; /* Environment variable for search path */
static char *ld_preload; /* Environment variable for libraries to
load first */
+static char *ld_elf_hints_path; /* Environment variable for alternative hints path */
static char *ld_tracing; /* Called from ldd to print libs */
static char *ld_utrace; /* Use utrace() to log events. */
static Obj_Entry *obj_list; /* Head of linked list of shared objects */
@@ -370,17 +371,23 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
unsetenv(LD_ "LIBRARY_PATH");
unsetenv(LD_ "LIBMAP_DISABLE");
unsetenv(LD_ "DEBUG");
+ unsetenv(LD_ "ELF_HINTS_PATH");
}
ld_debug = getenv(LD_ "DEBUG");
libmap_disable = getenv(LD_ "LIBMAP_DISABLE") != NULL;
libmap_override = getenv(LD_ "LIBMAP");
ld_library_path = getenv(LD_ "LIBRARY_PATH");
ld_preload = getenv(LD_ "PRELOAD");
+ ld_elf_hints_path = getenv(LD_ "ELF_HINTS_PATH");
dangerous_ld_env = libmap_disable || (libmap_override != NULL) ||
- (ld_library_path != NULL) || (ld_preload != NULL);
+ (ld_library_path != NULL) || (ld_preload != NULL) ||
+ (ld_elf_hints_path != NULL);
ld_tracing = getenv(LD_ "TRACE_LOADED_OBJECTS");
ld_utrace = getenv(LD_ "UTRACE");
+ if ((ld_elf_hints_path == NULL) || strlen(ld_elf_hints_path) == 0)
+ ld_elf_hints_path = _PATH_ELF_HINTS;
+
if (ld_debug != NULL && *ld_debug != '\0')
debug = 1;
dbg("%s is initialized, base address = %p", __progname,
@@ -1240,7 +1247,7 @@ gethints(void)
/* Keep from trying again in case the hints file is bad. */
hints = "";
- if ((fd = open(_PATH_ELF_HINTS, O_RDONLY)) == -1)
+ if ((fd = open(ld_elf_hints_path, O_RDONLY)) == -1)
return NULL;
if (read(fd, &hdr, sizeof hdr) != sizeof hdr ||
hdr.magic != ELFHINTS_MAGIC ||
OpenPOWER on IntegriCloud