aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-17 16:38:39 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-17 16:38:39 +0000
commitb12b6a188e50c3bad1f866bb7f8cdb42a8b0d56c (patch)
treed09c88ffbdbb9ef22ebc40fec5e51442d6e3041c /linux-user
parentffb04fcf089865952592f1f8855c2848d4514a89 (diff)
Option to drop LD_PRELOAD from emulated environment, by Lauri Leukkunen.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2985 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/main.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index fd96ea2c09..7df24c5a74 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1666,11 +1666,12 @@ void usage(void)
"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"
+ "-drop-ld-preload drop LD_PRELOAD for target process\n"
"\n"
"debug options:\n"
#ifdef USE_CODE_COPY
@@ -1702,7 +1703,9 @@ int main(int argc, char **argv)
int optind;
const char *r;
int gdbstub_port = 0;
-
+ int drop_ld_preload = 0, environ_count = 0;
+ char **target_environ, **wrk, **dst;
+
if (argc <= 1)
usage();
@@ -1774,6 +1777,8 @@ int main(int argc, char **argv)
#endif
_exit(1);
}
+ } else if (!strcmp(r, "drop-ld-preload")) {
+ drop_ld_preload = 1;
} else
#ifdef USE_CODE_COPY
if (!strcmp(r, "no-code-copy")) {
@@ -1802,11 +1807,31 @@ int main(int argc, char **argv)
env = cpu_init();
global_env = env;
- if (loader_exec(filename, argv+optind, environ, regs, info) != 0) {
- printf("Error loading %s\n", filename);
- _exit(1);
+ wrk = environ;
+ while (*(wrk++))
+ environ_count++;
+
+ target_environ = malloc((environ_count + 1) * sizeof(char *));
+ if (!target_environ)
+ abort();
+ for (wrk = environ, dst = target_environ; *wrk; wrk++) {
+ if (drop_ld_preload && !strncmp(*wrk, "LD_PRELOAD=", 11))
+ continue;
+ *(dst++) = strdup(*wrk);
+ }
+ dst = NULL; /* NULL terminate target_environ */
+
+ if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
+ printf("Error loading %s\n", filename);
+ _exit(1);
+ }
+
+ for (wrk = target_environ; *wrk; wrk++) {
+ free(*wrk);
}
+ free(target_environ);
+
if (loglevel) {
page_dump(logfile);