[BusyBox] ash running /etc/profile when started from inittab, take II

Erik Andersen andersen at codepoet.org
Mon Jul 22 22:44:03 UTC 2002


On Mon Jul 22, 2002 at 12:15:50PM -0600, rich_wilson at agilent.com wrote:
> Any attempt I make to run something called "-/bin/sh" from inittab seems doomed to failure.
> Am I missing something?
> My current try is 
>   ::respawn:-/bin/sh </dev/ttyS0 >/dev/ttyS0 2>/dev/ttyS0
> which just prints "ex" every second or so.  The serial console
> isn't too useful in this state!

Could you try the following patch and change your inittab entry to 
    ttyS0::respawn:-/bin/sh
and let me know if this helps?

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
-------------- next part --------------
diff -u -u -r1.165 init.c
--- init/init.c	3 Jul 2002 23:49:27 -0000	1.165
+++ init/init.c	18 Jul 2002 09:55:41 -0000
@@ -159,10 +159,6 @@
 
 /* Static variables */
 static struct init_action *init_action_list = NULL;
-static char *secondConsole = VC_2;
-static char *thirdConsole  = VC_3;
-static char *fourthConsole = VC_4;
-static char *log           = VC_5;
 static int  kernelVersion  = 0;
 static char termType[32]   = "TERM=linux";
 static char console[32]    = _PATH_CONSOLE;
@@ -223,15 +219,9 @@
 	/* Take full control of the log tty, and never close it.
 	 * It's mine, all mine!  Muhahahaha! */
 	if (log_fd < 0) {
-		if (log == NULL) {
-			/* don't even try to log, because there is no such console */
+		if ((log_fd = device_open(VC_5, O_RDWR|O_NDELAY)) < 0) {
 			log_fd = -2;
-			/* log to main console instead */
-			device = CONSOLE;
-		} else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
-			log_fd = -2;
-			fprintf(stderr, "Bummer, can't write to log on %s!\n", log);
-			log = NULL;
+			fprintf(stderr, "Bummer, can't write to log on %s!\n", VC_5);
 			device = CONSOLE;
 		}
 	}
@@ -381,19 +371,12 @@
 		/* Perhaps we should panic here? */
 		safe_strncpy(console, "/dev/null", sizeof(console));
 	} else {
-		/* check for serial console and disable logging to tty5 & 
-		 * running a shell to tty2-4 */
+		/* check for serial console */
 		if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
-			log = NULL;
-			secondConsole = NULL;
-			thirdConsole = NULL;
-			fourthConsole = NULL;
 			/* Force the TERM setting to vt102 for serial console --
-			 * iff TERM is set to linux (the default) */
+			 * if TERM is set to linux (the default) */
 			if (strcmp( termType, "TERM=linux" ) == 0)
 				safe_strncpy(termType, "TERM=vt102", sizeof(termType));
-			message(LOG | CONSOLE,
-					"\rserial console detected.  Disabling virtual terminals.\n");
 		}
 		close(fd);
 	}
@@ -802,9 +785,7 @@
 			/* Seems the s390 console is Wierd(tm). */
 			"\rThe system is halted. You may reboot now.\n"
 #else
-			/* secondConsole is NULL for a serial console */
-			"\rThe system is halted. Press %s or turn off power\n",
-			(secondConsole == NULL)? "Reset" : "CTRL-ALT-DEL"
+			"\rThe system is halted. Press Reset or turn off power\n"
 #endif
 		   );
 	sync();
@@ -865,12 +846,8 @@
 	if (*cons == '\0')
 		cons = console;
 
-	/* If BusyBox detects that a serial console is in use, then entries
-	 * not refering to the console or null devices will _not_ be run.
-	 * The exception to this rule is the null device.
-	 */
-	if (secondConsole == NULL && strcmp(cons, console)
-		&& strcmp(cons, "/dev/null"))
+	/* do not run entries if console device is not available */
+	if (access(cons, R_OK|W_OK))
 		return;
 	if (strcmp(cons, "/dev/null") == 0 && (action & ASKFIRST))
 		return;
@@ -944,17 +921,11 @@
 #endif
 		/* Prepare to restart init when a HUP is received */
 		new_init_action(RESTART, "/sbin/init", console);
-		/* Askfirst shell on tty1 */
+		/* Askfirst shell on tty1-4 */
 		new_init_action(ASKFIRST, LOGIN_SHELL, console);
-		/* Askfirst shell on tty2 */
-		if (secondConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole);
-		/* Askfirst shell on tty3 */
-		if (thirdConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
-		/* Askfirst shell on tty4 */
-		if (fourthConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_2);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_3);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_4);
 		/* sysinit */
 		new_init_action(SYSINIT, INIT_SCRIPT, console);
 
@@ -1113,12 +1084,9 @@
 	if (argc > 1 && (!strcmp(argv[1], "single") ||
 					 !strcmp(argv[1], "-s") || !strcmp(argv[1], "1"))) {
 		/* Ask first then start a shell on tty2-4 */
-		if (secondConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, secondConsole);
-		if (thirdConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, thirdConsole);
-		if (fourthConsole != NULL)
-			new_init_action(ASKFIRST, LOGIN_SHELL, fourthConsole);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_2);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_3);
+		new_init_action(ASKFIRST, LOGIN_SHELL, VC_4);
 		/* Start a shell on tty1 */
 		new_init_action(RESPAWN, LOGIN_SHELL, console);
 	} else {


More information about the busybox mailing list