svn commit: trunk/busybox: applets include libbb shell

vda at busybox.net vda at busybox.net
Fri Jun 8 15:03:00 UTC 2007


Author: vda
Date: 2007-06-08 08:02:55 -0700 (Fri, 08 Jun 2007)
New Revision: 18781

Log:
make busybox --install work even if /proc/self/exe doesn't exist

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 680095    2704   15648  698447   aa84f busybox_old
 680099    2704   15648  698451   aa853 busybox_unstripped



Modified:
   trunk/busybox/applets/applets.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/execable.c
   trunk/busybox/libbb/messages.c
   trunk/busybox/libbb/vfork_daemon_rexec.c
   trunk/busybox/shell/ash.c
   trunk/busybox/shell/hush.c
   trunk/busybox/shell/msh.c


Changeset:
Modified: trunk/busybox/applets/applets.c
===================================================================
--- trunk/busybox/applets/applets.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/applets/applets.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -577,21 +577,13 @@
 	}
 
 	if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
-		int use_symbolic_links = 0;
-		char *busybox;
-
-		/* to use symlinks, or not to use symlinks... */
-		if (argv[2])
-			if (strcmp(argv[2], "-s") == 0)
-				use_symbolic_links = 1;
-
-		/* link */
-		busybox = xmalloc_readlink_or_warn("/proc/self/exe");
+		const char *busybox;
+		busybox = xmalloc_readlink_or_warn(bb_busybox_exec_path);
 		if (!busybox)
-			return 1;
-		install_links(busybox, use_symbolic_links);
-		if (ENABLE_FEATURE_CLEAN_UP)
-			free(busybox);
+			busybox = bb_busybox_exec_path;
+		/* -s makes symlinks */
+		install_links(busybox,
+				 argv[2] && strcmp(argv[2], "-s") == 0);
 		return 0;
 	}
 

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/include/libbb.h	2007-06-08 15:02:55 UTC (rev 18781)
@@ -952,6 +952,7 @@
 extern const char bb_path_motd_file[];
 extern const char bb_path_wtmp_file[];
 extern const char bb_dev_null[];
+extern const char bb_busybox_exec_path[];
 
 extern const int const_int_0;
 extern const int const_int_1;

Modified: trunk/busybox/libbb/execable.c
===================================================================
--- trunk/busybox/libbb/execable.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/libbb/execable.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -65,7 +65,7 @@
  */
 int bb_execvp(const char *file, char *const argv[])
 {
-	return execvp(find_applet_by_name(file) ? CONFIG_BUSYBOX_EXEC_PATH : file,
+	return execvp(find_applet_by_name(file) ? bb_busybox_exec_path : file,
 					argv);
 }
 #endif

Modified: trunk/busybox/libbb/messages.c
===================================================================
--- trunk/busybox/libbb/messages.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/libbb/messages.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -37,8 +37,9 @@
 const char bb_path_nologin_file[] = "/etc/nologin";
 const char bb_path_securetty_file[] = "/etc/securetty";
 const char bb_path_motd_file[] = "/etc/motd";
+const char bb_dev_null[] = "/dev/null";
+const char bb_busybox_exec_path[] = CONFIG_BUSYBOX_EXEC_PATH;
 const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
-const char bb_dev_null[] = "/dev/null";
 
 const int const_int_0;
 const int const_int_1 = 1;

Modified: trunk/busybox/libbb/vfork_daemon_rexec.c
===================================================================
--- trunk/busybox/libbb/vfork_daemon_rexec.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/libbb/vfork_daemon_rexec.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -220,8 +220,8 @@
 	/* high-order bit of first char in argv[0] is a hidden
 	 * "we have (alrealy) re-execed, don't do it again" flag */
 	argv[0][0] |= 0x80;
-	execv(CONFIG_BUSYBOX_EXEC_PATH, argv);
-	bb_perror_msg_and_die("exec %s", CONFIG_BUSYBOX_EXEC_PATH);
+	execv(bb_busybox_exec_path, argv);
+	bb_perror_msg_and_die("exec %s", bb_busybox_exec_path);
 }
 #else
 /* Dance around (void)...*/

Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/shell/ash.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -6471,7 +6471,7 @@
 				run_current_applet_and_exit(argv);
 			}
 			/* re-exec ourselves with the new arguments */
-			execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp);
+			execve(bb_busybox_exec_path, argv, envp);
 			/* If they called chroot or otherwise made the binary no longer
 			 * executable, fall through */
 		}

Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/shell/hush.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -1392,7 +1392,7 @@
 			}
 			/* re-exec ourselves with the new arguments */
 			debug_printf_exec("re-execing applet '%s'\n", argv[0]);
-			execvp(CONFIG_BUSYBOX_EXEC_PATH, argv);
+			execvp(bb_busybox_exec_path, argv);
 			/* If they called chroot or otherwise made the binary no longer
 			 * executable, fall through */
 		}

Modified: trunk/busybox/shell/msh.c
===================================================================
--- trunk/busybox/shell/msh.c	2007-06-08 13:05:39 UTC (rev 18780)
+++ trunk/busybox/shell/msh.c	2007-06-08 15:02:55 UTC (rev 18781)
@@ -3062,7 +3062,7 @@
 			/* We have to exec here since we vforked.  Running
 			 * run_applet_and_exit() won't work and bad things
 			 * will happen. */
-			execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp);
+			execve(bb_busybox_exec_path, v, envp);
 		}
 	}
 




More information about the busybox-cvs mailing list