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

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


Replying to myself. Same patch with a local variable for argv_sh. It should
apply to both 2.4 and 2.5.

> 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=").

--- linux-2.4.18/init/main.c Mon Feb 25 20:38:13 2002
+++ linux/init/main.c Wed Feb 27 23:12:40 2002
@@ -804,6 +804,8 @@

static int init(void * unused)
{
+ static char * argv_sh[] = { "sh", NULL, };
+
lock_kernel();
do_basic_setup();

@@ -835,6 +837,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/