diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-01-08 22:04:33 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-01-08 22:04:33 +0000 |
commit | ac6e71f0c4150e9394b0a424e9d64750bcfacb85 (patch) | |
tree | fd16232c6d8a5a1b0f8ee3d2ca12a3cf2081f43a | |
parent | 766f9c7a191ba0b0682334068f3c78b29e04e8a0 (diff) | |
download | busybox-w32-ac6e71f0c4150e9394b0a424e9d64750bcfacb85.tar.gz busybox-w32-ac6e71f0c4150e9394b0a424e9d64750bcfacb85.tar.bz2 busybox-w32-ac6e71f0c4150e9394b0a424e9d64750bcfacb85.zip |
Possible fixes...
-Erik
-rw-r--r-- | init.c | 51 | ||||
-rw-r--r-- | init/init.c | 51 |
2 files changed, 68 insertions, 34 deletions
@@ -107,9 +107,10 @@ initAction* initActionList = NULL; | |||
107 | 107 | ||
108 | 108 | ||
109 | static char *console = _PATH_CONSOLE; | 109 | static char *console = _PATH_CONSOLE; |
110 | static char *second_console = VT_SECONDARY; | 110 | static char *secondConsole = VT_SECONDARY; |
111 | static char *log = VT_LOG; | 111 | static char *log = VT_LOG; |
112 | static int kernel_version = 0; | 112 | static int kernelVersion = 0; |
113 | static char *termType = NULL; | ||
113 | 114 | ||
114 | 115 | ||
115 | /* try to open up the specified device */ | 116 | /* try to open up the specified device */ |
@@ -258,6 +259,12 @@ static void console_init() | |||
258 | char *s; | 259 | char *s; |
259 | 260 | ||
260 | if ((s = getenv("CONSOLE")) != NULL) { | 261 | if ((s = getenv("CONSOLE")) != NULL) { |
262 | termType = s; | ||
263 | } else { | ||
264 | termType = "TERM=vt100"; | ||
265 | } | ||
266 | |||
267 | if ((s = getenv("CONSOLE")) != NULL) { | ||
261 | console = s; | 268 | console = s; |
262 | } | 269 | } |
263 | #if #cpu(sparc) | 270 | #if #cpu(sparc) |
@@ -314,7 +321,7 @@ static void console_init() | |||
314 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 321 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { |
315 | message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console ); | 322 | message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console ); |
316 | log = NULL; | 323 | log = NULL; |
317 | second_console = NULL; | 324 | secondConsole = NULL; |
318 | } | 325 | } |
319 | close(fd); | 326 | close(fd); |
320 | } | 327 | } |
@@ -330,9 +337,18 @@ static pid_t run(char* command, | |||
330 | char* cmd[255]; | 337 | char* cmd[255]; |
331 | static const char press_enter[] = | 338 | static const char press_enter[] = |
332 | "\nPlease press Enter to activate this console. "; | 339 | "\nPlease press Enter to activate this console. "; |
340 | static char * environment[] = { | ||
341 | "HOME=/", | ||
342 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", | ||
343 | "SHELL=/bin/sh", | ||
344 | 0, | ||
345 | "USER=root", | ||
346 | 0 | ||
347 | }; | ||
348 | environment[3]=termType; | ||
349 | |||
333 | 350 | ||
334 | if ((pid = fork()) == 0) { | 351 | if ((pid = fork()) == 0) { |
335 | int fd; | ||
336 | pid_t shell_pgid = getpid (); | 352 | pid_t shell_pgid = getpid (); |
337 | 353 | ||
338 | /* Clean up */ | 354 | /* Clean up */ |
@@ -341,14 +357,14 @@ static pid_t run(char* command, | |||
341 | close(2); | 357 | close(2); |
342 | setsid(); | 358 | setsid(); |
343 | 359 | ||
344 | if ((fd=device_open(terminal, O_RDWR)) < 0) { | 360 | if (device_open(terminal, O_RDWR) < 0) { |
345 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | 361 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); |
346 | exit(1); | 362 | exit(1); |
347 | } | 363 | } |
348 | dup(fd); | 364 | dup(0); |
349 | dup(fd); | 365 | dup(0); |
350 | set_term(fd); | 366 | tcsetpgrp (0, getpgrp()); |
351 | tcsetpgrp (fd, getpgrp()); | 367 | set_term(0); |
352 | 368 | ||
353 | /* Reset signal handlers set for parent process */ | 369 | /* Reset signal handlers set for parent process */ |
354 | signal(SIGUSR1, SIG_DFL); | 370 | signal(SIGUSR1, SIG_DFL); |
@@ -389,7 +405,8 @@ static pid_t run(char* command, | |||
389 | 405 | ||
390 | /* Now run it. The new program will take over this PID, | 406 | /* Now run it. The new program will take over this PID, |
391 | * so nothing further in init.c should be run. */ | 407 | * so nothing further in init.c should be run. */ |
392 | execvp(cmd[0], cmd); | 408 | //execvp(cmd[0], cmd); |
409 | execve(cmd[0], cmd, environment); | ||
393 | 410 | ||
394 | /* We're still here? Some error happened. */ | 411 | /* We're still here? Some error happened. */ |
395 | message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0], | 412 | message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0], |
@@ -464,7 +481,7 @@ static void shutdown_system(void) | |||
464 | message(CONSOLE, "Unmounting filesystems.\r\n"); | 481 | message(CONSOLE, "Unmounting filesystems.\r\n"); |
465 | waitfor("umount -a", console, FALSE); | 482 | waitfor("umount -a", console, FALSE); |
466 | sync(); | 483 | sync(); |
467 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { | 484 | if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) { |
468 | /* bdflush, kupdate not needed for kernels >2.2.11 */ | 485 | /* bdflush, kupdate not needed for kernels >2.2.11 */ |
469 | bdflush(1, 0); | 486 | bdflush(1, 0); |
470 | sync(); | 487 | sync(); |
@@ -505,7 +522,7 @@ void new_initAction (initActionEnum action, | |||
505 | /* If BusyBox detects that a serial console is in use, | 522 | /* If BusyBox detects that a serial console is in use, |
506 | * then entries containing non-empty id fields will _not_ be run. | 523 | * then entries containing non-empty id fields will _not_ be run. |
507 | */ | 524 | */ |
508 | if (second_console == NULL && *cons != '\0') { | 525 | if (secondConsole == NULL && *cons != '\0') { |
509 | return; | 526 | return; |
510 | } | 527 | } |
511 | 528 | ||
@@ -563,8 +580,8 @@ void parse_inittab(void) | |||
563 | /* Askfirst shell on tty1 */ | 580 | /* Askfirst shell on tty1 */ |
564 | new_initAction( ASKFIRST, SHELL, console ); | 581 | new_initAction( ASKFIRST, SHELL, console ); |
565 | /* Askfirst shell on tty2 */ | 582 | /* Askfirst shell on tty2 */ |
566 | if (second_console != NULL) | 583 | if (secondConsole != NULL) |
567 | new_initAction( ASKFIRST, SHELL, second_console ); | 584 | new_initAction( ASKFIRST, SHELL, secondConsole ); |
568 | /* sysinit */ | 585 | /* sysinit */ |
569 | new_initAction( SYSINIT, INIT_SCRIPT, console ); | 586 | new_initAction( SYSINIT, INIT_SCRIPT, console ); |
570 | 587 | ||
@@ -698,7 +715,7 @@ extern int init_main(int argc, char **argv) | |||
698 | /* Mount /proc */ | 715 | /* Mount /proc */ |
699 | if (mount ("proc", "/proc", "proc", 0, 0) == 0) { | 716 | if (mount ("proc", "/proc", "proc", 0, 0) == 0) { |
700 | message(LOG|CONSOLE, "Mounting /proc: done.\n"); | 717 | message(LOG|CONSOLE, "Mounting /proc: done.\n"); |
701 | kernel_version = get_kernel_revision(); | 718 | kernelVersion = get_kernel_revision(); |
702 | } else | 719 | } else |
703 | message(LOG|CONSOLE, "Mounting /proc: failed!\n"); | 720 | message(LOG|CONSOLE, "Mounting /proc: failed!\n"); |
704 | 721 | ||
@@ -710,8 +727,8 @@ extern int init_main(int argc, char **argv) | |||
710 | !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) | 727 | !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) |
711 | { | 728 | { |
712 | /* Ask first then start a shell on tty2 */ | 729 | /* Ask first then start a shell on tty2 */ |
713 | if (second_console != NULL) | 730 | if (secondConsole != NULL) |
714 | new_initAction( ASKFIRST, SHELL, second_console); | 731 | new_initAction( ASKFIRST, SHELL, secondConsole); |
715 | /* Ask first then start a shell on tty1 */ | 732 | /* Ask first then start a shell on tty1 */ |
716 | new_initAction( ASKFIRST, SHELL, console); | 733 | new_initAction( ASKFIRST, SHELL, console); |
717 | } else { | 734 | } else { |
diff --git a/init/init.c b/init/init.c index de4ac1c19..8a48380e9 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -107,9 +107,10 @@ initAction* initActionList = NULL; | |||
107 | 107 | ||
108 | 108 | ||
109 | static char *console = _PATH_CONSOLE; | 109 | static char *console = _PATH_CONSOLE; |
110 | static char *second_console = VT_SECONDARY; | 110 | static char *secondConsole = VT_SECONDARY; |
111 | static char *log = VT_LOG; | 111 | static char *log = VT_LOG; |
112 | static int kernel_version = 0; | 112 | static int kernelVersion = 0; |
113 | static char *termType = NULL; | ||
113 | 114 | ||
114 | 115 | ||
115 | /* try to open up the specified device */ | 116 | /* try to open up the specified device */ |
@@ -258,6 +259,12 @@ static void console_init() | |||
258 | char *s; | 259 | char *s; |
259 | 260 | ||
260 | if ((s = getenv("CONSOLE")) != NULL) { | 261 | if ((s = getenv("CONSOLE")) != NULL) { |
262 | termType = s; | ||
263 | } else { | ||
264 | termType = "TERM=vt100"; | ||
265 | } | ||
266 | |||
267 | if ((s = getenv("CONSOLE")) != NULL) { | ||
261 | console = s; | 268 | console = s; |
262 | } | 269 | } |
263 | #if #cpu(sparc) | 270 | #if #cpu(sparc) |
@@ -314,7 +321,7 @@ static void console_init() | |||
314 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 321 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { |
315 | message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console ); | 322 | message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console ); |
316 | log = NULL; | 323 | log = NULL; |
317 | second_console = NULL; | 324 | secondConsole = NULL; |
318 | } | 325 | } |
319 | close(fd); | 326 | close(fd); |
320 | } | 327 | } |
@@ -330,9 +337,18 @@ static pid_t run(char* command, | |||
330 | char* cmd[255]; | 337 | char* cmd[255]; |
331 | static const char press_enter[] = | 338 | static const char press_enter[] = |
332 | "\nPlease press Enter to activate this console. "; | 339 | "\nPlease press Enter to activate this console. "; |
340 | static char * environment[] = { | ||
341 | "HOME=/", | ||
342 | "PATH=/usr/bin:/bin:/usr/sbin:/sbin", | ||
343 | "SHELL=/bin/sh", | ||
344 | 0, | ||
345 | "USER=root", | ||
346 | 0 | ||
347 | }; | ||
348 | environment[3]=termType; | ||
349 | |||
333 | 350 | ||
334 | if ((pid = fork()) == 0) { | 351 | if ((pid = fork()) == 0) { |
335 | int fd; | ||
336 | pid_t shell_pgid = getpid (); | 352 | pid_t shell_pgid = getpid (); |
337 | 353 | ||
338 | /* Clean up */ | 354 | /* Clean up */ |
@@ -341,14 +357,14 @@ static pid_t run(char* command, | |||
341 | close(2); | 357 | close(2); |
342 | setsid(); | 358 | setsid(); |
343 | 359 | ||
344 | if ((fd=device_open(terminal, O_RDWR)) < 0) { | 360 | if (device_open(terminal, O_RDWR) < 0) { |
345 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); | 361 | message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal); |
346 | exit(1); | 362 | exit(1); |
347 | } | 363 | } |
348 | dup(fd); | 364 | dup(0); |
349 | dup(fd); | 365 | dup(0); |
350 | set_term(fd); | 366 | tcsetpgrp (0, getpgrp()); |
351 | tcsetpgrp (fd, getpgrp()); | 367 | set_term(0); |
352 | 368 | ||
353 | /* Reset signal handlers set for parent process */ | 369 | /* Reset signal handlers set for parent process */ |
354 | signal(SIGUSR1, SIG_DFL); | 370 | signal(SIGUSR1, SIG_DFL); |
@@ -389,7 +405,8 @@ static pid_t run(char* command, | |||
389 | 405 | ||
390 | /* Now run it. The new program will take over this PID, | 406 | /* Now run it. The new program will take over this PID, |
391 | * so nothing further in init.c should be run. */ | 407 | * so nothing further in init.c should be run. */ |
392 | execvp(cmd[0], cmd); | 408 | //execvp(cmd[0], cmd); |
409 | execve(cmd[0], cmd, environment); | ||
393 | 410 | ||
394 | /* We're still here? Some error happened. */ | 411 | /* We're still here? Some error happened. */ |
395 | message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0], | 412 | message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0], |
@@ -464,7 +481,7 @@ static void shutdown_system(void) | |||
464 | message(CONSOLE, "Unmounting filesystems.\r\n"); | 481 | message(CONSOLE, "Unmounting filesystems.\r\n"); |
465 | waitfor("umount -a", console, FALSE); | 482 | waitfor("umount -a", console, FALSE); |
466 | sync(); | 483 | sync(); |
467 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { | 484 | if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) { |
468 | /* bdflush, kupdate not needed for kernels >2.2.11 */ | 485 | /* bdflush, kupdate not needed for kernels >2.2.11 */ |
469 | bdflush(1, 0); | 486 | bdflush(1, 0); |
470 | sync(); | 487 | sync(); |
@@ -505,7 +522,7 @@ void new_initAction (initActionEnum action, | |||
505 | /* If BusyBox detects that a serial console is in use, | 522 | /* If BusyBox detects that a serial console is in use, |
506 | * then entries containing non-empty id fields will _not_ be run. | 523 | * then entries containing non-empty id fields will _not_ be run. |
507 | */ | 524 | */ |
508 | if (second_console == NULL && *cons != '\0') { | 525 | if (secondConsole == NULL && *cons != '\0') { |
509 | return; | 526 | return; |
510 | } | 527 | } |
511 | 528 | ||
@@ -563,8 +580,8 @@ void parse_inittab(void) | |||
563 | /* Askfirst shell on tty1 */ | 580 | /* Askfirst shell on tty1 */ |
564 | new_initAction( ASKFIRST, SHELL, console ); | 581 | new_initAction( ASKFIRST, SHELL, console ); |
565 | /* Askfirst shell on tty2 */ | 582 | /* Askfirst shell on tty2 */ |
566 | if (second_console != NULL) | 583 | if (secondConsole != NULL) |
567 | new_initAction( ASKFIRST, SHELL, second_console ); | 584 | new_initAction( ASKFIRST, SHELL, secondConsole ); |
568 | /* sysinit */ | 585 | /* sysinit */ |
569 | new_initAction( SYSINIT, INIT_SCRIPT, console ); | 586 | new_initAction( SYSINIT, INIT_SCRIPT, console ); |
570 | 587 | ||
@@ -698,7 +715,7 @@ extern int init_main(int argc, char **argv) | |||
698 | /* Mount /proc */ | 715 | /* Mount /proc */ |
699 | if (mount ("proc", "/proc", "proc", 0, 0) == 0) { | 716 | if (mount ("proc", "/proc", "proc", 0, 0) == 0) { |
700 | message(LOG|CONSOLE, "Mounting /proc: done.\n"); | 717 | message(LOG|CONSOLE, "Mounting /proc: done.\n"); |
701 | kernel_version = get_kernel_revision(); | 718 | kernelVersion = get_kernel_revision(); |
702 | } else | 719 | } else |
703 | message(LOG|CONSOLE, "Mounting /proc: failed!\n"); | 720 | message(LOG|CONSOLE, "Mounting /proc: failed!\n"); |
704 | 721 | ||
@@ -710,8 +727,8 @@ extern int init_main(int argc, char **argv) | |||
710 | !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) | 727 | !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) |
711 | { | 728 | { |
712 | /* Ask first then start a shell on tty2 */ | 729 | /* Ask first then start a shell on tty2 */ |
713 | if (second_console != NULL) | 730 | if (secondConsole != NULL) |
714 | new_initAction( ASKFIRST, SHELL, second_console); | 731 | new_initAction( ASKFIRST, SHELL, secondConsole); |
715 | /* Ask first then start a shell on tty1 */ | 732 | /* Ask first then start a shell on tty1 */ |
716 | new_initAction( ASKFIRST, SHELL, console); | 733 | new_initAction( ASKFIRST, SHELL, console); |
717 | } else { | 734 | } else { |