Date: Mon, 23 Mar 2009 16:49:00 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190324 - head/libexec/rtld-elf Message-ID: <200903231649.n2NGn0fY014995@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Mon Mar 23 16:49:00 2009 New Revision: 190324 URL: http://svn.freebsd.org/changeset/base/190324 Log: 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 Modified: head/libexec/rtld-elf/rtld.1 head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.1 ============================================================================== --- head/libexec/rtld-elf/rtld.1 Mon Mar 23 16:20:39 2009 (r190323) +++ head/libexec/rtld-elf/rtld.1 Mon Mar 23 16:49:00 2009 (r190324) @@ -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. Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Mar 23 16:20:39 2009 (r190323) +++ head/libexec/rtld-elf/rtld.c Mon Mar 23 16:49:00 2009 (r190324) @@ -162,6 +162,7 @@ static char *ld_debug; /* Environment v 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_ 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 ||
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903231649.n2NGn0fY014995>