qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Make user-mode emu drop LD_PRELOAD
@ 2007-04-22 19:39 Lauri Leukkunen
  2007-04-22 20:03 ` Paul Brook
  0 siblings, 1 reply; 3+ messages in thread
From: Lauri Leukkunen @ 2007-04-22 19:39 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 159 bytes --]

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

[-- Attachment #2: qemu-linux-user-drop-preload.diff --]
[-- Type: text/x-patch, Size: 1933 bytes --]

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Make user-mode emu drop LD_PRELOAD
  2007-04-22 19:39 [Qemu-devel] [PATCH] Make user-mode emu drop LD_PRELOAD Lauri Leukkunen
@ 2007-04-22 20:03 ` Paul Brook
  2007-04-22 20:37   ` Lauri Leukkunen
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Brook @ 2007-04-22 20:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: Lauri Leukkunen

On Sunday 22 April 2007 20:39, Lauri Leukkunen wrote:
> This patch makes user-mode emulation drop LD_PRELOAD environment variable
> by default and adds an option "-keep-ld-preload" to override this
> behaviour.

Why?

Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] Make user-mode emu drop LD_PRELOAD
  2007-04-22 20:03 ` Paul Brook
@ 2007-04-22 20:37   ` Lauri Leukkunen
  0 siblings, 0 replies; 3+ messages in thread
From: Lauri Leukkunen @ 2007-04-22 20:37 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

On 4/22/07, Paul Brook <paul@codesourcery.com> wrote:
> On Sunday 22 April 2007 20:39, Lauri Leukkunen wrote:
> > This patch makes user-mode emulation drop LD_PRELOAD environment variable
> > by default and adds an option "-keep-ld-preload" to override this
> > behaviour.
>
> Why?

My use case is for scratchbox 2, I want to have libsb2.so preloaded
for qemu-arm itself, but I don't want the target process to have to
load it as there is no such library for it.

I just realized that this patch is probably not doing the right thing
anyway, I think it should modify the target process environment in
loader_exec instead of unsetting it for qemu itself, end result is
more or less the same for simple cases, but I need to check where the
environment is inherited from if the emulated process execs another.

/lauri

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-22 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-22 19:39 [Qemu-devel] [PATCH] Make user-mode emu drop LD_PRELOAD Lauri Leukkunen
2007-04-22 20:03 ` Paul Brook
2007-04-22 20:37   ` Lauri Leukkunen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).