diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-20 18:01:50 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-02-20 18:01:50 +0000 |
commit | ab9dcd3b6b30f1e4833189f8c413b6d1e5aef71e (patch) | |
tree | 11a80d2a43d8fb3b2e5b0a02b84b051ae24f88e4 /init | |
parent | 28dfea04927ebf0f661d0dcdf70c3660636e0e23 (diff) | |
download | busybox-w32-ab9dcd3b6b30f1e4833189f8c413b6d1e5aef71e.tar.gz busybox-w32-ab9dcd3b6b30f1e4833189f8c413b6d1e5aef71e.tar.bz2 busybox-w32-ab9dcd3b6b30f1e4833189f8c413b6d1e5aef71e.zip |
Commit a patch from Erik Gustavsson <cyrano@algonet.se>, to allow
environment variables set from the kernel command line to be inherited
bu application programs. Slightly changed to special case handling of
TERM, so that it has sane defaults when on a serial console.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1869 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/init/init.c b/init/init.c index 1332a1064..4c05c38e3 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -134,6 +134,7 @@ static _syscall2(int, bdflush, int, func, int, data); | |||
134 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ | 134 | #define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | static const int MAXENV = 16; /* Number of env. vars */ | ||
137 | static const int LOG = 0x1; | 138 | static const int LOG = 0x1; |
138 | static const int CONSOLE = 0x2; | 139 | static const int CONSOLE = 0x2; |
139 | 140 | ||
@@ -394,7 +395,8 @@ static void console_init() | |||
394 | 395 | ||
395 | static pid_t run(char *command, char *terminal, int get_enter) | 396 | static pid_t run(char *command, char *terminal, int get_enter) |
396 | { | 397 | { |
397 | int i, fd; | 398 | int i=0, j=0; |
399 | int fd; | ||
398 | pid_t pid; | 400 | pid_t pid; |
399 | char *tmpCmd; | 401 | char *tmpCmd; |
400 | char *cmd[255], *cmdpath; | 402 | char *cmd[255], *cmdpath; |
@@ -406,15 +408,24 @@ static pid_t run(char *command, char *terminal, int get_enter) | |||
406 | #endif | 408 | #endif |
407 | 409 | ||
408 | "\nPlease press Enter to activate this console. "; | 410 | "\nPlease press Enter to activate this console. "; |
409 | char *environment[] = { | 411 | char *environment[MAXENV+1] = { |
410 | "HOME=/", | 412 | "HOME=/", |
411 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", | 413 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", |
412 | "SHELL=/bin/sh", | 414 | "SHELL=/bin/sh", |
413 | termType, | 415 | termType, |
414 | "USER=root", | 416 | "USER=root" |
415 | 0 | ||
416 | }; | 417 | }; |
417 | 418 | ||
419 | while (environment[i]) i++; | ||
420 | while ((environ[j]) && (i < MAXENV)) { | ||
421 | if (strncmp(environ[j], "TERM=", 5)) | ||
422 | environment[i++] = environ[j]; | ||
423 | else { | ||
424 | snprintf(termType, sizeof(termType) - 1, environ[j]); | ||
425 | } | ||
426 | j++; | ||
427 | } | ||
428 | |||
418 | if ((pid = fork()) == 0) { | 429 | if ((pid = fork()) == 0) { |
419 | /* Clean up */ | 430 | /* Clean up */ |
420 | ioctl(0, TIOCNOTTY, 0); | 431 | ioctl(0, TIOCNOTTY, 0); |