Package: fakechroot Version: 2.17.2-1 Severity: minor Tags: patch Dear Maintainer,
In a fakechroot environment, invoking chroot twice gives some strange results : 1/ absolute paths for newroot cause an error $ fakechroot fakeroot chroot my_first_chroot # cd home # chroot /home/me/my_second_chroot ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded: ignored. ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded: ignored. $ echo $LD_LIBRARY_PATH /home/me/my_first_chroot/home/me/my_second_chroot/usr/lib:/home/me/my_first_chroot/home/me/my_second_chroot/lib (the path of libfakeroot disappeared) or $ fakechroot fakeroot chroot my_first_chroot # chroot . /usr/sbin/chroot: cannot change root directory to : No such file or directory 2/ relative paths for newroot are followed, but : a/ non existent paths are added to LD_LIBRARY_PATH $ fakechroot fakeroot chroot my_first_chroot # chroot home/me/my_second_chroot The output of # echo $LD_LIBRARY_PATH is attached (LD_LIBRARY_PATH.1). Paths "/home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/*" don't exist. FAKECHROOT_BASE_ORIG (ie /home/me/my_first_chroot) is added twice to the components of LD_LIBRARY_PATH, and kept after newroot. b/ paths inside the previous (fake)chroot are kept in LD_LIBRARY_PATH. They would be forgotten in a real chroot. What is the correct policy for fakechroot ? In the previous example, do we have to keep /home/me/my_first_chroot/usr/lib/x86_64-linux-gnu/libfakeroot: /home/me/my_first_chroot/usr/lib64/libfakeroot: /home/me/my_first_chroot/usr/lib32/libfakeroot: /home/me/my_first_chroot/usr/local/lib: /home/me/my_first_chroot/lib/x86_64-linux-gnu: /home/me/my_first_chroot/usr/lib/x86_64-linux-gnu in LD_LIBRARY_PATH ? Thanks for your comments or corrections ! Regards, JH Chatenet *** rustine11.patch diff -Naur a/scripts/chroot.fakechroot.sh b/scripts/chroot.fakechroot.sh --- a/scripts/chroot.fakechroot.sh 2014-03-12 15:28:05.000000000 +0100 +++ b/scripts/chroot.fakechroot.sh 2014-03-16 17:50:26.000000000 +0100 @@ -39,6 +39,12 @@ fakechroot_chroot_base="$FAKECHROOT_BASE_ORIG" +# records the content of LD_LIBRARY_PATH at first chroot invocation +if [ -z "$fakechroot_chroot_base" -a -n "$LD_LIBRARY_PATH" ]; then + FAKECHROOT_LDLIBPATH="$LD_LIBRARY_PATH" + export FAKECHROOT_LDLIBPATH +fi + fakechroot_chroot_n=1 for fakechroot_chroot_opt in "$@"; do case "$fakechroot_chroot_opt" in @@ -46,36 +52,42 @@ continue ;; *) - fakechroot_chroot_newroot="$fakechroot_chroot_opt" + fakechroot_chroot_requested_newroot="$fakechroot_chroot_opt" break ;; esac fakechroot_chroot_n=$(($fakechroot_chroot_n + 1)) done +# absolute paths in fakechroot_chroot_opt are relative to FAKECHROOT_BASE_ORIG +if [ "${fakechroot_chroot_requested_newroot#/}" != "$fakechroot_chroot_requested_newroot" ]; then + fakechroot_chroot_newroot="${fakechroot_chroot_base}${fakechroot_chroot_requested_newroot}" +else + fakechroot_chroot_newroot="$fakechroot_chroot_requested_newroot" +fi if [ -d "$fakechroot_chroot_newroot" ]; then - fakechroot_chroot_newroot=`cd "$fakechroot_chroot_opt"; pwd -P` + fakechroot_chroot_newroot=`cd "$fakechroot_chroot_newroot"; pwd -P` fakechroot_chroot_paths= # append newroot to each directory from original LD_LIBRARY_PATH fakechroot_chroot_IFS_bak="$IFS" IFS=: - for fakechroot_chroot_d in $LD_LIBRARY_PATH; do - fakechroot_chroot_paths="${fakechroot_chroot_paths:+$fakechroot_chroot_paths:}$fakechroot_chroot_base$fakechroot_chroot_newroot/${fakechroot_chroot_d#/}" + for fakechroot_chroot_d in $FAKECHROOT_LDLIBPATH; do + fakechroot_chroot_paths="${fakechroot_chroot_paths:+$fakechroot_chroot_paths:}$fakechroot_chroot_newroot/${fakechroot_chroot_d#/}" done IFS="$fakechroot_chroot_IFS_bak" # append newroot to each directory from new /etc/ld.so.conf fakechroot_chroot_paths_ldsoconf="" if [ -f "$fakechroot_chroot_newroot/etc/ld.so.conf" ]; then - fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s%s" "$fakechroot_chroot_base" "$fakechroot_chroot_line"; done` + fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s" "$fakechroot_chroot_line"; done` elif [ -d "$fakechroot_chroot_newroot/etc/ld.so.conf.d" ]; then - fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf.d/*" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s%s" "$fakechroot_chroot_base" "$fakechroot_chroot_line"; done` + fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf.d/*" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s" "$fakechroot_chroot_line"; done` fi fakechroot_chroot_paths_ldsoconf="${fakechroot_chroot_paths_ldsoconf#:}" - fakechroot_chroot_paths="$fakechroot_chroot_paths${fakechroot_chroot_paths_ldsoconf:+:$fakechroot_chroot_paths_ldsoconf}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + fakechroot_chroot_paths="$fakechroot_chroot_paths${fakechroot_chroot_paths_ldsoconf:+:$fakechroot_chroot_paths_ldsoconf}${FAKECHROOT_LDLIBPATH:+:$FAKECHROOT_LDLIBPATH}" fakechroot_chroot_paths="${fakechroot_chroot_paths#:}" fi @@ -83,7 +95,7 @@ if [ -n "$fakechroot_chroot_newroot" ] && ( test "$1" = "${@:1:$((1+0))}" ) 2>/dev/null && [ $fakechroot_chroot_n -le $# ]; then # shell with arrays and built-in expr env -u FAKECHROOT_BASE_ORIG FAKECHROOT_CMD_ORIG= LD_LIBRARY_PATH="$fakechroot_chroot_paths" FAKECHROOT_BASE="$fakechroot_chroot_base" \ - "$fakechroot_chroot_chroot" "${@:1:$(($fakechroot_chroot_n - 1))}" "${fakechroot_chroot_newroot#$FAKECHROOT_BASE_ORIG}" "${@:$(($fakechroot_chroot_n + 1))}" + "$fakechroot_chroot_chroot" "${@:1:$(($fakechroot_chroot_n - 1))}" "$fakechroot_chroot_requested_newroot" "${@:$(($fakechroot_chroot_n + 1))}" exit $? else # POSIX shell diff -Naur a/src/libfakechroot.c b/src/libfakechroot.c --- a/src/libfakechroot.c 2014-03-16 11:12:23.000000000 +0100 +++ b/src/libfakechroot.c 2014-03-16 10:41:48.000000000 +0100 @@ -55,6 +55,7 @@ "FAKECHROOT_ELFLOADER", "FAKECHROOT_ELFLOADER_OPT_ARGV0", "FAKECHROOT_EXCLUDE_PATH", + "FAKECHROOT_LDLIBPATH", "FAKECHROOT_VERSION", "FAKEROOTKEY", "FAKED_MODE", -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/dash Versions of packages fakechroot depends on: ii libfakechroot 2.17.2-1 fakechroot recommends no packages. fakechroot suggests no packages. -- no debconf information
# echo $LD_LIBRARY_PATH /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/lib/x86_64-linux-gnu/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/lib64/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/lib32/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/local/lib: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/lib/x86_64-linux-gnu: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/lib/x86_64-linux-gnu: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/usr/lib/x86_64-linux-gnu/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/usr/lib64/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/usr/lib32/libfakeroot: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/usr/lib: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/home/me/my_first_chroot/lib: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/usr/local/lib: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/lib/x86_64-linux-gnu: /home/me/my_first_chroot/home/me/my_first_chroot/home/me/my_second_chroot/usr/lib/x86_64-linux-gnu: /home/me/my_first_chroot/usr/lib/x86_64-linux-gnu/libfakeroot: /home/me/my_first_chroot/usr/lib64/libfakeroot: /home/me/my_first_chroot/usr/lib32/libfakeroot: /home/me/my_first_chroot/usr/local/lib: /home/me/my_first_chroot/lib/x86_64-linux-gnu: /home/me/my_first_chroot/usr/lib/x86_64-linux-gnu: /usr/lib/x86_64-linux-gnu/libfakeroot: /usr/lib64/libfakeroot: /usr/lib32/libfakeroot: /home/me/my_first_chroot/usr/lib: /home/me/my_first_chroot/lib: /home/me/my_first_chroot/home/me/my_second_chroot/usr/lib: /home/me/my_first_chroot/home/me/my_second_chroot/lib