[BUG] execve("/bin/sh"...) in init/main.c

Eric Swalens (eric.swalens@easynet.be)
Wed, 27 Feb 2002 21:21:39 +0100


If init cannot be executed, the init(.) function in init/main.c falls back to
sh and calls execve("/bin/sh", argv_init, envp_init).

But if there is no "init=" in the command line, argv_init can contain
something (most likely the "auto" preprended by lilo) and the shell will
terminate immediately. (parse_options(.) does not handle this case since it
does not find "init=").

I used the simple patch below to correct the problem.

Eric

--- linux-2.4.18/init/main.c Mon Feb 25 20:38:13 2002
+++ linux/init/main.c Wed Feb 27 18:46:51 2002
@@ -130,6 +130,7 @@
char root_device_name[64];

+static char * argv_sh[2] = { "sh", NULL };
static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
static char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };

@@ -835,6 +836,6 @@
execve("/sbin/init",argv_init,envp_init);
execve("/etc/init",argv_init,envp_init);
execve("/bin/init",argv_init,envp_init);
- execve("/bin/sh",argv_init,envp_init);
+ execve("/bin/sh",argv_sh,envp_init);
panic("No init found. Try passing init= option to kernel.");
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/