diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-06 06:02:31 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-06 06:02:31 +0100 |
commit | 4a2a86d5e7e7bf284a31af604a738dfa1f1a2240 (patch) | |
tree | 6f936d5089180f582856e67d2694b1b1b8df7985 /libbb/appletlib.c | |
parent | 7cfe6ea99e78f82b068216faac4739eaaebaaa8b (diff) | |
download | busybox-w32-4a2a86d5e7e7bf284a31af604a738dfa1f1a2240.tar.gz busybox-w32-4a2a86d5e7e7bf284a31af604a738dfa1f1a2240.tar.bz2 busybox-w32-4a2a86d5e7e7bf284a31af604a738dfa1f1a2240.zip |
improve --install operation in chroot jails
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/appletlib.c')
-rw-r--r-- | libbb/appletlib.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index fc3e962d5..69cac2e9a 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -713,12 +713,23 @@ static int busybox_main(char **argv) | |||
713 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { | 713 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { |
714 | int use_symbolic_links; | 714 | int use_symbolic_links; |
715 | const char *busybox; | 715 | const char *busybox; |
716 | |||
716 | busybox = xmalloc_readlink(bb_busybox_exec_path); | 717 | busybox = xmalloc_readlink(bb_busybox_exec_path); |
717 | if (!busybox) | 718 | if (!busybox) { |
718 | busybox = bb_busybox_exec_path; | 719 | /* bb_busybox_exec_path is usually "/proc/self/exe". |
719 | /* busybox --install [-s] [DIR]: */ | 720 | * In chroot, readlink("/proc/self/exe") usually fails. |
720 | /* -s: make symlinks */ | 721 | * In such case, better use argv[0] as symlink target |
721 | /* DIR: directory to install links to */ | 722 | * if it is a full path name. |
723 | */ | ||
724 | if (argv[0][0] == '/') | ||
725 | busybox = argv[0]; | ||
726 | else | ||
727 | busybox = bb_busybox_exec_path; | ||
728 | } | ||
729 | /* busybox --install [-s] [DIR]: | ||
730 | * -s: make symlinks | ||
731 | * DIR: directory to install links to | ||
732 | */ | ||
722 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && argv++); | 733 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && argv++); |
723 | install_links(busybox, use_symbolic_links, argv[2]); | 734 | install_links(busybox, use_symbolic_links, argv[2]); |
724 | return 0; | 735 | return 0; |