svn commit: r292810 - in head/libexec/rtld-elf: . arm

Warner Losh imp at FreeBSD.org
Sun Dec 27 23:04:14 UTC 2015


Author: imp
Date: Sun Dec 27 23:04:12 2015
New Revision: 292810
URL: https://svnweb.freebsd.org/changeset/base/292810

Log:
  Use a macro to create the names for the library path names. This will
  allow later substitution at run time instead of compile time of the
  environment variable name prefix.
  
  Differential Review: https://reviews.freebsd.org/D2718

Modified:
  head/libexec/rtld-elf/arm/reloc.c
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/arm/reloc.c
==============================================================================
--- head/libexec/rtld-elf/arm/reloc.c	Sun Dec 27 23:04:11 2015	(r292809)
+++ head/libexec/rtld-elf/arm/reloc.c	Sun Dec 27 23:04:12 2015	(r292810)
@@ -15,6 +15,7 @@ __FBSDID("$FreeBSD$");
 
 #include "debug.h"
 #include "rtld.h"
+#include "paths.h"
 
 void
 init_pltgot(Obj_Entry *obj)

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Sun Dec 27 23:04:11 2015	(r292809)
+++ head/libexec/rtld-elf/rtld.c	Sun Dec 27 23:04:12 2015	(r292810)
@@ -204,6 +204,8 @@ extern Elf_Dyn _DYNAMIC;
 #define	RTLD_IS_DYNAMIC()	(&_DYNAMIC != NULL)
 #endif
 
+#define _LD(x)	LD_ x
+
 int dlclose(void *) __exported;
 char *dlerror(void) __exported;
 void *dlopen(const char *, int) __exported;
@@ -417,7 +419,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
 
     trust = !issetugid();
 
-    ld_bind_now = getenv(LD_ "BIND_NOW");
+    ld_bind_now = getenv(_LD("BIND_NOW"));
     /* 
      * If the process is tainted, then we un-set the dangerous environment
      * variables.  The process will be marked as tainted until setuid(2)
@@ -425,24 +427,24 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
      * future processes to honor the potentially un-safe variables.
      */
     if (!trust) {
-        if (unsetenv(LD_ "PRELOAD") || unsetenv(LD_ "LIBMAP") ||
-	    unsetenv(LD_ "LIBRARY_PATH") || unsetenv(LD_ "LIBRARY_PATH_FDS") ||
-	    unsetenv(LD_ "LIBMAP_DISABLE") ||
-	    unsetenv(LD_ "DEBUG") || unsetenv(LD_ "ELF_HINTS_PATH") ||
-	    unsetenv(LD_ "LOADFLTR") || unsetenv(LD_ "LIBRARY_PATH_RPATH")) {
+	if (unsetenv(_LD("PRELOAD")) || unsetenv(_LD("LIBMAP")) ||
+	    unsetenv(_LD("LIBRARY_PATH")) || unsetenv(_LD("LIBRARY_PATH_FDS")) ||
+	    unsetenv(_LD("LIBMAP_DISABLE")) ||
+	    unsetenv(_LD("DEBUG")) || unsetenv(_LD("ELF_HINTS_PATH")) ||
+	    unsetenv(_LD("LOADFLTR")) || unsetenv(_LD("LIBRARY_PATH_RPATH"))) {
 		_rtld_error("environment corrupt; aborting");
 		rtld_die();
 	}
     }
-    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_library_dirs = getenv(LD_ "LIBRARY_PATH_FDS");
-    ld_preload = getenv(LD_ "PRELOAD");
-    ld_elf_hints_path = getenv(LD_ "ELF_HINTS_PATH");
-    ld_loadfltr = getenv(LD_ "LOADFLTR") != NULL;
-    library_path_rpath = getenv(LD_ "LIBRARY_PATH_RPATH");
+    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_library_dirs = getenv(_LD("LIBRARY_PATH_FDS"));
+    ld_preload = getenv(_LD("PRELOAD"));
+    ld_elf_hints_path = getenv(_LD("ELF_HINTS_PATH"));
+    ld_loadfltr = getenv(_LD("LOADFLTR")) != NULL;
+    library_path_rpath = getenv(_LD("LIBRARY_PATH_RPATH"));
     if (library_path_rpath != NULL) {
 	    if (library_path_rpath[0] == 'y' ||
 		library_path_rpath[0] == 'Y' ||
@@ -454,8 +456,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
     dangerous_ld_env = libmap_disable || (libmap_override != NULL) ||
 	(ld_library_path != NULL) || (ld_preload != NULL) ||
 	(ld_elf_hints_path != NULL) || ld_loadfltr;
-    ld_tracing = getenv(LD_ "TRACE_LOADED_OBJECTS");
-    ld_utrace = getenv(LD_ "UTRACE");
+    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 = ld_elf_hints_default;
@@ -592,7 +594,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
 	exit(0);
     }
 
-    if (getenv(LD_ "DUMP_REL_PRE") != NULL) {
+    if (getenv(_LD("DUMP_REL_PRE")) != NULL) {
        dump_relocations(obj_main);
        exit (0);
     }
@@ -620,7 +622,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
     if (do_copy_relocations(obj_main) == -1)
 	rtld_die();
 
-    if (getenv(LD_ "DUMP_REL_POST") != NULL) {
+    if (getenv(_LD("DUMP_REL_POST")) != NULL) {
        dump_relocations(obj_main);
        exit (0);
     }
@@ -4177,16 +4179,16 @@ trace_loaded_objects(Obj_Entry *obj)
     char	*fmt1, *fmt2, *fmt, *main_local, *list_containers;
     int		c;
 
-    if ((main_local = getenv(LD_ "TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
+    if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
 	main_local = "";
 
-    if ((fmt1 = getenv(LD_ "TRACE_LOADED_OBJECTS_FMT1")) == NULL)
+    if ((fmt1 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT1"))) == NULL)
 	fmt1 = "\t%o => %p (%x)\n";
 
-    if ((fmt2 = getenv(LD_ "TRACE_LOADED_OBJECTS_FMT2")) == NULL)
+    if ((fmt2 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT2"))) == NULL)
 	fmt2 = "\t%o (%x)\n";
 
-    list_containers = getenv(LD_ "TRACE_LOADED_OBJECTS_ALL");
+    list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL"));
 
     for (; obj; obj = obj->next) {
 	Needed_Entry		*needed;


More information about the svn-src-head mailing list