aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.c19
-rw-r--r--init/init.c19
2 files changed, 30 insertions, 8 deletions
diff --git a/init.c b/init.c
index 1332a1064..4c05c38e3 100644
--- a/init.c
+++ b/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);
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);