[BusyBox 0000708]: switch_root parses init parameters wrongly

bugs at busybox.net bugs at busybox.net
Sun Feb 12 23:28:44 UTC 2006


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=708 
====================================================================== 
Reported By:                hel
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   708
Category:                   Other
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             02-09-2006 05:03 PST
Last Modified:              02-12-2006 15:28 PST
====================================================================== 
Summary:                    switch_root parses init parameters wrongly
Description: 
I could reproduce this problem with busybox r13886 compiled statically
against uclibc --- used in an initramfs

the command
switch_root -c /dev/console /mnt/newroot /sbin/init 1
does not deliver the "1" over to init

however
switch_root -c /dev/console /mnt/newroot /sbin/init dummy 1
does start init in the correct runlevel.
====================================================================== 

---------------------------------------------------------------------- 
 brain0 - 02-12-06 15:28  
---------------------------------------------------------------------- 
I have the same issue, but even worse. Because of a wrong execv call,
/sbin/init will hang forever after I do
exec /sbin/switch_root /new_root /sbin/init
This is because the first argument passed by all exec calls should be the
program name itself. This patch fixes it:

diff -ur busybox-1.1.0.orig/util-linux/switch_root.c
busybox-1.1.0/util-linux/switch_root.c
--- busybox-1.1.0.orig/util-linux/switch_root.c	2006-01-11
06:44:22.000000000 +0100
+++ busybox-1.1.0/util-linux/switch_root.c	2006-02-12 21:47:37.000000000
+0100
@@ -118,6 +118,6 @@
 	}
 
 	// Exec real init.  (This is why we must be pid 1.)
-	execv(argv[optind],argv+optind+1);
+	execv(argv[optind],argv+optind);
 	bb_error_msg_and_die("Bad init '%s'",argv[optind]);
 } 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
02-09-06 05:03  hel            New Issue                                    
02-09-06 05:03  hel            Status                   new => assigned     
02-09-06 05:03  hel            Assigned To               => BusyBox         
02-12-06 15:28  brain0         Note Added: 0001085                          
======================================================================




More information about the busybox-cvs mailing list