From: Erik Andersen <andersen@codepoet.org>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com.br>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix 2.4.x incorrect argv[0] for init
Date: Tue, 9 Sep 2003 16:32:18 -0600 [thread overview]
Message-ID: <20030909223218.GA11277@codepoet.org> (raw)
In both 2.4.x and in 2.6.x, when someone specifies "init=" to
select an alternative binary to run instead of /sbin/init,
argv[0] is not set correctly. This is a problem for programs
such as busybox that multiplex applications based on the value of
argv[0]. For example, even if you specify init=/bin/sh" on the
kernel command line, busybox will still receive "/sbin/init" as
argv[0], and will therefore run init rather than /bin/sh...
This patch fixes it. Please apply,
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
--- orig/init/main.c 2003-08-30 10:50:15.000000000 -0600
+++ linux-2.4.22/init/main.c 2003-08-30 10:50:15.000000000 -0600
@@ -545,6 +545,12 @@
#endif
}
+static void run_init_process(char *init_filename)
+{
+ argv_init[0] = init_filename;
+ execve(init_filename, argv_init, envp_init);
+}
+
extern void prepare_namespace(void);
static int init(void * unused)
@@ -587,10 +593,12 @@
*/
if (execute_command)
- execve(execute_command,argv_init,envp_init);
- 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);
+ run_init_process(execute_command);
+
+ run_init_process("/sbin/init");
+ run_init_process("/etc/init");
+ run_init_process("/bin/init");
+ run_init_process("/bin/sh");
+
panic("No init found. Try passing init= option to kernel.");
}
next reply other threads:[~2003-09-09 22:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-09 22:32 Erik Andersen [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-10-01 17:44 Linux 2.4.23-pre6 Marcelo Tosatti
2003-10-01 18:56 ` [PATCH] fix 2.4.x incorrect argv[0] for init Erik Andersen
2003-10-01 19:34 ` jhf
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=20030909223218.GA11277@codepoet.org \
--to=andersen@codepoet.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com.br \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.