lkml.org 
[lkml]   [2002]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] execve("/bin/sh"...) in init/main.c
Date
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/
\
 
 \ /
  Last update: 2005-03-22 13:24    [from the cache]
©2003-2011 Jasper Spaans