This patch makes user-mode emulation drop LD_PRELOAD environment variable
by default and adds an option "-keep-ld-preload" to override this behaviour.

/lauri
Index: linux-user/main.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/main.c,v
retrieving revision 1.108
diff -u -r1.108 main.c
--- linux-user/main.c	14 Apr 2007 12:17:09 -0000	1.108
+++ linux-user/main.c	22 Apr 2007 19:36:43 -0000
@@ -1642,11 +1642,12 @@
            "usage: qemu-" TARGET_ARCH " [-h] [-g] [-d opts] [-L path] [-s size] [-cpu model] program [arguments...]\n"
            "Linux CPU emulator (compiled for %s emulation)\n"
            "\n"
-           "-h           print this help\n"
-           "-g port      wait gdb connection to port\n"
-           "-L path      set the elf interpreter prefix (default=%s)\n"
-           "-s size      set the stack size in bytes (default=%ld)\n"
-           "-cpu model   select CPU (-cpu ? for list)\n"
+           "-h                print this help\n"
+           "-g port           wait gdb connection to port\n"
+           "-L path           set the elf interpreter prefix (default=%s)\n"
+           "-s size           set the stack size in bytes (default=%ld)\n"
+           "-cpu model        select CPU (-cpu ? for list)\n"
+           "-keep-ld-preload  retain LD_PRELOAD\n"
            "\n"
            "debug options:\n"
 #ifdef USE_CODE_COPY
@@ -1678,7 +1679,8 @@
     int optind;
     const char *r;
     int gdbstub_port = 0;
-    
+    int keep_ld_preload = 0;
+
     if (argc <= 1)
         usage();
 
@@ -1750,6 +1752,8 @@
 #endif
                 _exit(1);
             }
+        } else if (!strcmp(r, "keep-ld-preload")) {
+            keep_ld_preload = 1;
         } else 
 #ifdef USE_CODE_COPY
         if (!strcmp(r, "no-code-copy")) {
@@ -1778,6 +1782,8 @@
     env = cpu_init();
     global_env = env;
     
+    if (!keep_ld_preload) unsetenv("LD_PRELOAD");
+
     if (loader_exec(filename, argv+optind, environ, regs, info) != 0) {
 	printf("Error loading %s\n", filename);
 	_exit(1);

Reply via email to