aboutsummaryrefslogtreecommitdiff
path: root/libbb/appletlib.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-03-06 06:02:31 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-03-06 06:02:31 +0100
commit4a2a86d5e7e7bf284a31af604a738dfa1f1a2240 (patch)
tree6f936d5089180f582856e67d2694b1b1b8df7985 /libbb/appletlib.c
parent7cfe6ea99e78f82b068216faac4739eaaebaaa8b (diff)
downloadbusybox-4a2a86d5e7e7bf284a31af604a738dfa1f1a2240.tar.gz
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.c21
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)
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
int use_symbolic_links;
const char *busybox;
+
busybox = xmalloc_readlink(bb_busybox_exec_path);
- if (!busybox)
- busybox = bb_busybox_exec_path;
- /* busybox --install [-s] [DIR]: */
- /* -s: make symlinks */
- /* DIR: directory to install links to */
+ if (!busybox) {
+ /* bb_busybox_exec_path is usually "/proc/self/exe".
+ * In chroot, readlink("/proc/self/exe") usually fails.
+ * In such case, better use argv[0] as symlink target
+ * if it is a full path name.
+ */
+ if (argv[0][0] == '/')
+ busybox = argv[0];
+ else
+ busybox = bb_busybox_exec_path;
+ }
+ /* busybox --install [-s] [DIR]:
+ * -s: make symlinks
+ * DIR: directory to install links to
+ */
use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && argv++);
install_links(busybox, use_symbolic_links, argv[2]);
return 0;