Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 May 2009 02:17:25 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r192008 - stable/7/libexec/rtld-elf
Message-ID:  <200905120217.n4C2HPW7008442@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Tue May 12 02:17:25 2009
New Revision: 192008
URL: http://svn.freebsd.org/changeset/base/192008

Log:
  MFC r190324:
  
  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:
  stable/7/libexec/rtld-elf/   (props changed)
  stable/7/libexec/rtld-elf/rtld.1
  stable/7/libexec/rtld-elf/rtld.c

Modified: stable/7/libexec/rtld-elf/rtld.1
==============================================================================
--- stable/7/libexec/rtld-elf/rtld.1	Tue May 12 02:08:56 2009	(r192007)
+++ stable/7/libexec/rtld-elf/rtld.1	Tue May 12 02:17:25 2009	(r192008)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 27, 2006
+.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: stable/7/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/7/libexec/rtld-elf/rtld.c	Tue May 12 02:08:56 2009	(r192007)
+++ stable/7/libexec/rtld-elf/rtld.c	Tue May 12 02:17:25 2009	(r192008)
@@ -157,6 +157,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 */
@@ -365,17 +366,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,
@@ -1094,7 +1101,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?200905120217.n4C2HPW7008442>