diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-16 01:14:04 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-16 01:14:04 +0000 |
commit | 1f2c6c1629952e69d2c303cb7c90c82d25ab2a8b (patch) | |
tree | 7995a486b9aacb1afd7cc86004c5cd1f94881955 /init | |
parent | ecf3e07bc4dd17548ad5a2f2c0d6e93fe73ce747 (diff) | |
download | busybox-w32-1f2c6c1629952e69d2c303cb7c90c82d25ab2a8b.tar.gz busybox-w32-1f2c6c1629952e69d2c303cb7c90c82d25ab2a8b.tar.bz2 busybox-w32-1f2c6c1629952e69d2c303cb7c90c82d25ab2a8b.zip |
A patch from Andreas Neuhaus to be especially careful to not dup
any env variables when spawning child processes.
git-svn-id: svn://busybox.net/trunk/busybox@2116 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/init/init.c b/init/init.c index 64c7768d6..145452ff3 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -396,11 +396,11 @@ static void console_init() | |||
396 | 396 | ||
397 | static pid_t run(char *command, char *terminal, int get_enter) | 397 | static pid_t run(char *command, char *terminal, int get_enter) |
398 | { | 398 | { |
399 | int i=0, j=0; | 399 | int i, j; |
400 | int fd; | 400 | int fd; |
401 | pid_t pid; | 401 | pid_t pid; |
402 | char *tmpCmd; | 402 | char *tmpCmd, *s; |
403 | char *cmd[255], *cmdpath; | 403 | char *cmd[255], *cmdpath; |
404 | char buf[255]; | 404 | char buf[255]; |
405 | static const char press_enter[] = | 405 | static const char press_enter[] = |
406 | 406 | ||
@@ -410,18 +410,25 @@ static pid_t run(char *command, char *terminal, int get_enter) | |||
410 | 410 | ||
411 | "\nPlease press Enter to activate this console. "; | 411 | "\nPlease press Enter to activate this console. "; |
412 | char *environment[MAXENV+1] = { | 412 | char *environment[MAXENV+1] = { |
413 | termType, | ||
413 | "HOME=/", | 414 | "HOME=/", |
414 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", | 415 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", |
415 | "SHELL=/bin/sh", | 416 | "SHELL=/bin/sh", |
416 | termType, | 417 | "USER=root", |
417 | "USER=root" | 418 | NULL |
418 | }; | 419 | }; |
419 | 420 | ||
420 | while (environment[i]) i++; | 421 | /* inherit environment to the child, merging our values -andy */ |
421 | while ((environ[j]) && (i < MAXENV)) { | 422 | for (i=0; environ[i]; i++) { |
422 | if (strncmp(environ[j], "TERM=", 5)) | 423 | for (j=0; environment[j]; j++) { |
423 | environment[i++] = environ[j]; | 424 | s = strchr(environment[j], '='); |
424 | j++; | 425 | if (!strncmp(environ[i], environment[j], s - environment[j])) |
426 | break; | ||
427 | } | ||
428 | if (!environment[j]) { | ||
429 | environment[j++] = environ[i]; | ||
430 | environment[j] = NULL; | ||
431 | } | ||
425 | } | 432 | } |
426 | 433 | ||
427 | if ((pid = fork()) == 0) { | 434 | if ((pid = fork()) == 0) { |