static char *console = _PATH_CONSOLE;
-static char *second_console = VT_SECONDARY;
+static char *secondConsole = VT_SECONDARY;
static char *log = VT_LOG;
-static int kernel_version = 0;
+static int kernelVersion = 0;
+static char *termType = NULL;
/* try to open up the specified device */
struct serial_struct sr;
char *s;
+ if ((s = getenv("CONSOLE")) != NULL) {
+ termType = s;
+ } else {
+ termType = "TERM=vt100";
+ }
+
if ((s = getenv("CONSOLE")) != NULL) {
console = s;
}
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console );
log = NULL;
- second_console = NULL;
+ secondConsole = NULL;
}
close(fd);
}
char* cmd[255];
static const char press_enter[] =
"\nPlease press Enter to activate this console. ";
+ static char * environment[] = {
+ "HOME=/",
+ "PATH=/usr/bin:/bin:/usr/sbin:/sbin",
+ "SHELL=/bin/sh",
+ 0,
+ "USER=root",
+ 0
+ };
+ environment[3]=termType;
+
if ((pid = fork()) == 0) {
- int fd;
pid_t shell_pgid = getpid ();
/* Clean up */
close(2);
setsid();
- if ((fd=device_open(terminal, O_RDWR)) < 0) {
+ if (device_open(terminal, O_RDWR) < 0) {
message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal);
exit(1);
}
- dup(fd);
- dup(fd);
- set_term(fd);
- tcsetpgrp (fd, getpgrp());
+ dup(0);
+ dup(0);
+ tcsetpgrp (0, getpgrp());
+ set_term(0);
/* Reset signal handlers set for parent process */
signal(SIGUSR1, SIG_DFL);
/* Now run it. The new program will take over this PID,
* so nothing further in init.c should be run. */
- execvp(cmd[0], cmd);
+ //execvp(cmd[0], cmd);
+ execve(cmd[0], cmd, environment);
/* We're still here? Some error happened. */
message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0],
message(CONSOLE, "Unmounting filesystems.\r\n");
waitfor("umount -a", console, FALSE);
sync();
- if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
+ if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) {
/* bdflush, kupdate not needed for kernels >2.2.11 */
bdflush(1, 0);
sync();
/* If BusyBox detects that a serial console is in use,
* then entries containing non-empty id fields will _not_ be run.
*/
- if (second_console == NULL && *cons != '\0') {
+ if (secondConsole == NULL && *cons != '\0') {
return;
}
/* Askfirst shell on tty1 */
new_initAction( ASKFIRST, SHELL, console );
/* Askfirst shell on tty2 */
- if (second_console != NULL)
- new_initAction( ASKFIRST, SHELL, second_console );
+ if (secondConsole != NULL)
+ new_initAction( ASKFIRST, SHELL, secondConsole );
/* sysinit */
new_initAction( SYSINIT, INIT_SCRIPT, console );
/* Mount /proc */
if (mount ("proc", "/proc", "proc", 0, 0) == 0) {
message(LOG|CONSOLE, "Mounting /proc: done.\n");
- kernel_version = get_kernel_revision();
+ kernelVersion = get_kernel_revision();
} else
message(LOG|CONSOLE, "Mounting /proc: failed!\n");
!strcmp(argv[1], "-s") || !strcmp(argv[1], "1")))
{
/* Ask first then start a shell on tty2 */
- if (second_console != NULL)
- new_initAction( ASKFIRST, SHELL, second_console);
+ if (secondConsole != NULL)
+ new_initAction( ASKFIRST, SHELL, secondConsole);
/* Ask first then start a shell on tty1 */
new_initAction( ASKFIRST, SHELL, console);
} else {
static char *console = _PATH_CONSOLE;
-static char *second_console = VT_SECONDARY;
+static char *secondConsole = VT_SECONDARY;
static char *log = VT_LOG;
-static int kernel_version = 0;
+static int kernelVersion = 0;
+static char *termType = NULL;
/* try to open up the specified device */
struct serial_struct sr;
char *s;
+ if ((s = getenv("CONSOLE")) != NULL) {
+ termType = s;
+ } else {
+ termType = "TERM=vt100";
+ }
+
if ((s = getenv("CONSOLE")) != NULL) {
console = s;
}
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
message(LOG|CONSOLE, "serial console detected. Disabling virtual terminals.\r\n", console );
log = NULL;
- second_console = NULL;
+ secondConsole = NULL;
}
close(fd);
}
char* cmd[255];
static const char press_enter[] =
"\nPlease press Enter to activate this console. ";
+ static char * environment[] = {
+ "HOME=/",
+ "PATH=/usr/bin:/bin:/usr/sbin:/sbin",
+ "SHELL=/bin/sh",
+ 0,
+ "USER=root",
+ 0
+ };
+ environment[3]=termType;
+
if ((pid = fork()) == 0) {
- int fd;
pid_t shell_pgid = getpid ();
/* Clean up */
close(2);
setsid();
- if ((fd=device_open(terminal, O_RDWR)) < 0) {
+ if (device_open(terminal, O_RDWR) < 0) {
message(LOG|CONSOLE, "Bummer, can't open %s\r\n", terminal);
exit(1);
}
- dup(fd);
- dup(fd);
- set_term(fd);
- tcsetpgrp (fd, getpgrp());
+ dup(0);
+ dup(0);
+ tcsetpgrp (0, getpgrp());
+ set_term(0);
/* Reset signal handlers set for parent process */
signal(SIGUSR1, SIG_DFL);
/* Now run it. The new program will take over this PID,
* so nothing further in init.c should be run. */
- execvp(cmd[0], cmd);
+ //execvp(cmd[0], cmd);
+ execve(cmd[0], cmd, environment);
/* We're still here? Some error happened. */
message(LOG|CONSOLE, "Bummer, could not run '%s': %s\n", cmd[0],
message(CONSOLE, "Unmounting filesystems.\r\n");
waitfor("umount -a", console, FALSE);
sync();
- if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
+ if (kernelVersion > 0 && kernelVersion <= 2 * 65536 + 2 * 256 + 11) {
/* bdflush, kupdate not needed for kernels >2.2.11 */
bdflush(1, 0);
sync();
/* If BusyBox detects that a serial console is in use,
* then entries containing non-empty id fields will _not_ be run.
*/
- if (second_console == NULL && *cons != '\0') {
+ if (secondConsole == NULL && *cons != '\0') {
return;
}
/* Askfirst shell on tty1 */
new_initAction( ASKFIRST, SHELL, console );
/* Askfirst shell on tty2 */
- if (second_console != NULL)
- new_initAction( ASKFIRST, SHELL, second_console );
+ if (secondConsole != NULL)
+ new_initAction( ASKFIRST, SHELL, secondConsole );
/* sysinit */
new_initAction( SYSINIT, INIT_SCRIPT, console );
/* Mount /proc */
if (mount ("proc", "/proc", "proc", 0, 0) == 0) {
message(LOG|CONSOLE, "Mounting /proc: done.\n");
- kernel_version = get_kernel_revision();
+ kernelVersion = get_kernel_revision();
} else
message(LOG|CONSOLE, "Mounting /proc: failed!\n");
!strcmp(argv[1], "-s") || !strcmp(argv[1], "1")))
{
/* Ask first then start a shell on tty2 */
- if (second_console != NULL)
- new_initAction( ASKFIRST, SHELL, second_console);
+ if (secondConsole != NULL)
+ new_initAction( ASKFIRST, SHELL, secondConsole);
/* Ask first then start a shell on tty1 */
new_initAction( ASKFIRST, SHELL, console);
} else {