diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-08 15:02:55 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-08 15:02:55 +0000 |
commit | bdbbb7ec49040563628758a2581a5f8e44f53277 (patch) | |
tree | 040fdad2cf7f793717c7088c24047b654732541b | |
parent | c14d39e83a7f55ab9b92e98673a281fd6565c32d (diff) | |
download | busybox-w32-bdbbb7ec49040563628758a2581a5f8e44f53277.tar.gz busybox-w32-bdbbb7ec49040563628758a2581a5f8e44f53277.tar.bz2 busybox-w32-bdbbb7ec49040563628758a2581a5f8e44f53277.zip |
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
-rw-r--r-- | applets/applets.c | 20 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/execable.c | 2 | ||||
-rw-r--r-- | libbb/messages.c | 3 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 4 | ||||
-rw-r--r-- | shell/ash.c | 2 | ||||
-rw-r--r-- | shell/hush.c | 2 | ||||
-rw-r--r-- | shell/msh.c | 2 |
8 files changed, 15 insertions, 21 deletions
diff --git a/applets/applets.c b/applets/applets.c index bd3704394..f34124252 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -577,21 +577,13 @@ static int busybox_main(char **argv) | |||
577 | } | 577 | } |
578 | 578 | ||
579 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { | 579 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { |
580 | int use_symbolic_links = 0; | 580 | const char *busybox; |
581 | char *busybox; | 581 | busybox = xmalloc_readlink_or_warn(bb_busybox_exec_path); |
582 | |||
583 | /* to use symlinks, or not to use symlinks... */ | ||
584 | if (argv[2]) | ||
585 | if (strcmp(argv[2], "-s") == 0) | ||
586 | use_symbolic_links = 1; | ||
587 | |||
588 | /* link */ | ||
589 | busybox = xmalloc_readlink_or_warn("/proc/self/exe"); | ||
590 | if (!busybox) | 582 | if (!busybox) |
591 | return 1; | 583 | busybox = bb_busybox_exec_path; |
592 | install_links(busybox, use_symbolic_links); | 584 | /* -s makes symlinks */ |
593 | if (ENABLE_FEATURE_CLEAN_UP) | 585 | install_links(busybox, |
594 | free(busybox); | 586 | argv[2] && strcmp(argv[2], "-s") == 0); |
595 | return 0; | 587 | return 0; |
596 | } | 588 | } |
597 | 589 | ||
diff --git a/include/libbb.h b/include/libbb.h index 1ba122a2d..a32a74253 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -952,6 +952,7 @@ extern const char bb_path_securetty_file[]; | |||
952 | extern const char bb_path_motd_file[]; | 952 | extern const char bb_path_motd_file[]; |
953 | extern const char bb_path_wtmp_file[]; | 953 | extern const char bb_path_wtmp_file[]; |
954 | extern const char bb_dev_null[]; | 954 | extern const char bb_dev_null[]; |
955 | extern const char bb_busybox_exec_path[]; | ||
955 | 956 | ||
956 | extern const int const_int_0; | 957 | extern const int const_int_0; |
957 | extern const int const_int_1; | 958 | extern const int const_int_1; |
diff --git a/libbb/execable.c b/libbb/execable.c index d84364753..f679108be 100644 --- a/libbb/execable.c +++ b/libbb/execable.c | |||
@@ -65,7 +65,7 @@ int exists_execable(const char *filename) | |||
65 | */ | 65 | */ |
66 | int bb_execvp(const char *file, char *const argv[]) | 66 | int bb_execvp(const char *file, char *const argv[]) |
67 | { | 67 | { |
68 | return execvp(find_applet_by_name(file) ? CONFIG_BUSYBOX_EXEC_PATH : file, | 68 | return execvp(find_applet_by_name(file) ? bb_busybox_exec_path : file, |
69 | argv); | 69 | argv); |
70 | } | 70 | } |
71 | #endif | 71 | #endif |
diff --git a/libbb/messages.c b/libbb/messages.c index fbd882c43..16aaea553 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -37,8 +37,9 @@ const char bb_path_gshadow_file[] = "/etc/gshadow"; | |||
37 | const char bb_path_nologin_file[] = "/etc/nologin"; | 37 | const char bb_path_nologin_file[] = "/etc/nologin"; |
38 | const char bb_path_securetty_file[] = "/etc/securetty"; | 38 | const char bb_path_securetty_file[] = "/etc/securetty"; |
39 | const char bb_path_motd_file[] = "/etc/motd"; | 39 | const char bb_path_motd_file[] = "/etc/motd"; |
40 | const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; | ||
41 | const char bb_dev_null[] = "/dev/null"; | 40 | const char bb_dev_null[] = "/dev/null"; |
41 | const char bb_busybox_exec_path[] = CONFIG_BUSYBOX_EXEC_PATH; | ||
42 | const char bb_default_login_shell[] = LIBBB_DEFAULT_LOGIN_SHELL; | ||
42 | 43 | ||
43 | const int const_int_0; | 44 | const int const_int_0; |
44 | const int const_int_1 = 1; | 45 | const int const_int_1 = 1; |
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 349628796..cb4dee799 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -220,8 +220,8 @@ void forkexit_or_rexec(char **argv) | |||
220 | /* high-order bit of first char in argv[0] is a hidden | 220 | /* high-order bit of first char in argv[0] is a hidden |
221 | * "we have (alrealy) re-execed, don't do it again" flag */ | 221 | * "we have (alrealy) re-execed, don't do it again" flag */ |
222 | argv[0][0] |= 0x80; | 222 | argv[0][0] |= 0x80; |
223 | execv(CONFIG_BUSYBOX_EXEC_PATH, argv); | 223 | execv(bb_busybox_exec_path, argv); |
224 | bb_perror_msg_and_die("exec %s", CONFIG_BUSYBOX_EXEC_PATH); | 224 | bb_perror_msg_and_die("exec %s", bb_busybox_exec_path); |
225 | } | 225 | } |
226 | #else | 226 | #else |
227 | /* Dance around (void)...*/ | 227 | /* Dance around (void)...*/ |
diff --git a/shell/ash.c b/shell/ash.c index ea10a65cf..29d8713b7 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6471,7 +6471,7 @@ tryexec(char *cmd, char **argv, char **envp) | |||
6471 | run_current_applet_and_exit(argv); | 6471 | run_current_applet_and_exit(argv); |
6472 | } | 6472 | } |
6473 | /* re-exec ourselves with the new arguments */ | 6473 | /* re-exec ourselves with the new arguments */ |
6474 | execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp); | 6474 | execve(bb_busybox_exec_path, argv, envp); |
6475 | /* If they called chroot or otherwise made the binary no longer | 6475 | /* If they called chroot or otherwise made the binary no longer |
6476 | * executable, fall through */ | 6476 | * executable, fall through */ |
6477 | } | 6477 | } |
diff --git a/shell/hush.c b/shell/hush.c index 2a4076ed2..40bcafdd9 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1392,7 +1392,7 @@ static void pseudo_exec_argv(char **argv) | |||
1392 | } | 1392 | } |
1393 | /* re-exec ourselves with the new arguments */ | 1393 | /* re-exec ourselves with the new arguments */ |
1394 | debug_printf_exec("re-execing applet '%s'\n", argv[0]); | 1394 | debug_printf_exec("re-execing applet '%s'\n", argv[0]); |
1395 | execvp(CONFIG_BUSYBOX_EXEC_PATH, argv); | 1395 | execvp(bb_busybox_exec_path, argv); |
1396 | /* If they called chroot or otherwise made the binary no longer | 1396 | /* If they called chroot or otherwise made the binary no longer |
1397 | * executable, fall through */ | 1397 | * executable, fall through */ |
1398 | } | 1398 | } |
diff --git a/shell/msh.c b/shell/msh.c index d81a00122..aab805ff5 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
@@ -3062,7 +3062,7 @@ static const char *rexecve(char *c, char **v, char **envp) | |||
3062 | /* We have to exec here since we vforked. Running | 3062 | /* We have to exec here since we vforked. Running |
3063 | * run_applet_and_exit() won't work and bad things | 3063 | * run_applet_and_exit() won't work and bad things |
3064 | * will happen. */ | 3064 | * will happen. */ |
3065 | execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp); | 3065 | execve(bb_busybox_exec_path, v, envp); |
3066 | } | 3066 | } |
3067 | } | 3067 | } |
3068 | 3068 | ||