aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-20 18:01:50 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-20 18:01:50 +0000
commit477aedd77f5e4abeefbf686e21f395686aca16d3 (patch)
tree11a80d2a43d8fb3b2e5b0a02b84b051ae24f88e4 /init
parent5165fbed639916e0fde15a827241b21981be7934 (diff)
downloadbusybox-w32-477aedd77f5e4abeefbf686e21f395686aca16d3.tar.gz
busybox-w32-477aedd77f5e4abeefbf686e21f395686aca16d3.tar.bz2
busybox-w32-477aedd77f5e4abeefbf686e21f395686aca16d3.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
Diffstat (limited to 'init')
-rw-r--r--init/init.c19
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
137static const int MAXENV = 16; /* Number of env. vars */
137static const int LOG = 0x1; 138static const int LOG = 0x1;
138static const int CONSOLE = 0x2; 139static const int CONSOLE = 0x2;
139 140
@@ -394,7 +395,8 @@ static void console_init()
394 395
395static pid_t run(char *command, char *terminal, int get_enter) 396static 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);