make busybox --install work even if /proc/self/exe doesn't exist
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 8 Jun 2007 15:02:55 +0000 (15:02 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 8 Jun 2007 15:02:55 +0000 (15:02 -0000)
# 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

applets/applets.c
include/libbb.h
libbb/execable.c
libbb/messages.c
libbb/vfork_daemon_rexec.c
shell/ash.c
shell/hush.c
shell/msh.c

index bd37043940887d2ed46e7156151288de55050a9e..f3412425206dc404a0943568ad2f140fbb8300a7 100644 (file)
@@ -577,21 +577,13 @@ static int busybox_main(char **argv)
        }
 
        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;
        }
 
index 1ba122a2d2974e65849ecd9c779299dcb7c53ca8..a32a742535357f445ec20326601a451a068c77df 100644 (file)
@@ -952,6 +952,7 @@ extern const char bb_path_securetty_file[];
 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;
index d84364753bfd40d6a70daf496d123de185c9e290..f679108be2a989ec8a5ffbb88948cf54b1aa4a59 100644 (file)
@@ -65,7 +65,7 @@ int exists_execable(const char *filename)
  */
 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
index fbd882c43e92b5043625ade9a1089ce84146c715..16aaea5532342d663eb9c0c0e2ad7ab20f27e88c 100644 (file)
@@ -37,8 +37,9 @@ const char bb_path_gshadow_file[] = "/etc/gshadow";
 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_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL;
 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 int const_int_0;
 const int const_int_1 = 1;
index 349628796f9da7830f916ddd5f3b35f5d4c1fa7b..cb4dee79984e51a4dc9b3bf5797790339146feb9 100644 (file)
@@ -220,8 +220,8 @@ void forkexit_or_rexec(char **argv)
        /* 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)...*/
index ea10a65cf0b5b57caf9fc92d75445ed7624c7082..29d8713b7c803e93682b207de272aa98cae69061 100644 (file)
@@ -6471,7 +6471,7 @@ tryexec(char *cmd, char **argv, char **envp)
                                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 */
                }
index 2a4076ed2b44e49d1d31265986ef91dc5ade2e6f..40bcafdd92b50832341ba891307f8aee407b2596 100644 (file)
@@ -1392,7 +1392,7 @@ static void pseudo_exec_argv(char **argv)
                        }
                        /* 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 */
                }
index d81a001220f797a0f87377e7f99d1528798148f2..aab805ff5ac7c5f8b83d1e819baaf144d5d84ba7 100644 (file)
@@ -3062,7 +3062,7 @@ static const char *rexecve(char *c, char **v, char **envp)
                        /* 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);
                }
        }