aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/init.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/init/init.c b/init/init.c
index da79d101d..5c7efe210 100644
--- a/init/init.c
+++ b/init/init.c
@@ -273,6 +273,9 @@ static void console_init(void)
273 while (fd > 2) close(fd--); 273 while (fd > 2) close(fd--);
274 } 274 }
275 messageD(L_LOG, "console='%s'", s); 275 messageD(L_LOG, "console='%s'", s);
276 } else {
277 /* Make sure fd 0,1,2 are not closed */
278 bb_sanitize_stdio();
276 } 279 }
277 280
278 s = getenv("TERM"); 281 s = getenv("TERM");
@@ -288,20 +291,14 @@ static void console_init(void)
288 putenv((char*)"TERM=linux"); 291 putenv((char*)"TERM=linux");
289} 292}
290 293
291static void fixup_argv(int argc, char **argv, const char *new_argv0) 294static void fixup_argv(char **argv)
292{ 295{
293 int len;
294
295 /* Fix up argv[0] to be certain we claim to be init */ 296 /* Fix up argv[0] to be certain we claim to be init */
296 len = strlen(argv[0]); 297 strncpy(argv[0], "init", strlen(argv[0]));
297 strncpy(argv[0], new_argv0, len);
298 298
299 /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ 299 /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
300 len = 1; 300 while (*++argv)
301 while (argc > len) { 301 memset(*argv, 0, strlen(*argv));
302 memset(argv[len], 0, strlen(argv[len]));
303 len++;
304 }
305} 302}
306 303
307/* Open the new terminal device */ 304/* Open the new terminal device */
@@ -919,6 +916,7 @@ int init_main(int argc, char **argv)
919 init_reboot(RB_DISABLE_CAD); 916 init_reboot(RB_DISABLE_CAD);
920#endif 917#endif
921 918
919
922 /* Figure out where the default console should be */ 920 /* Figure out where the default console should be */
923 console_init(); 921 console_init();
924 set_sane_term(); 922 set_sane_term();
@@ -972,7 +970,7 @@ int init_main(int argc, char **argv)
972 if (getenv("SELINUX_INIT") == NULL) { 970 if (getenv("SELINUX_INIT") == NULL) {
973 int enforce = 0; 971 int enforce = 0;
974 972
975 putenv("SELINUX_INIT=YES"); 973 putenv((char*)"SELINUX_INIT=YES");
976 if (selinux_init_load_policy(&enforce) == 0) { 974 if (selinux_init_load_policy(&enforce) == 0) {
977 BB_EXECVP(argv[0], argv); 975 BB_EXECVP(argv[0], argv);
978 } else if (enforce > 0) { 976 } else if (enforce > 0) {
@@ -986,7 +984,7 @@ int init_main(int argc, char **argv)
986#endif /* CONFIG_SELINUX */ 984#endif /* CONFIG_SELINUX */
987 985
988 /* Make the command line just say "init" -- thats all, nothing else */ 986 /* Make the command line just say "init" -- thats all, nothing else */
989 fixup_argv(argc, argv, "init"); 987 fixup_argv(argv);
990 988
991 /* Now run everything that needs to be run */ 989 /* Now run everything that needs to be run */
992 990