From: Eric Swalens <eric.swalens@easynet.be>
To: linux-kernel@vger.kernel.org
Subject: [BUG] execve("/bin/sh"...) in init/main.c
Date: Wed, 27 Feb 2002 21:21:39 +0100 [thread overview]
Message-ID: <E16gAZm-0000W3-00@bigglesworth.mail.be.easynet.net> (raw)
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.");
}
next reply other threads:[~2002-02-27 20:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-27 20:21 Eric Swalens [this message]
2002-02-27 22:27 ` [PATCH] execve("/bin/sh"...) in init/main.c Eric Swalens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E16gAZm-0000W3-00@bigglesworth.mail.be.easynet.net \
--to=eric.swalens@easynet.be \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).