Code: Select all
#!/bin/bash
# debugging only
rm -rf /tmp/chroot
# Set up chroot directory
mkdir /tmp/chroot
pushd /tmp/chroot
mkdir bin etc lib var home
# Copy in the relevant parts of the system
APPS="/bin/bash /bin/ls /bin/mkdir /bin/mv /bin/pwd /bin/rm /bin/ping"
for prog in $APPS; do
echo "===========";
echo $prog;
#sleep 1
cp $prog ./ --parents
# obtain a list of related libraries
ldd $prog > /dev/null
if [ "$?" = 0 ] ; then
LIBS=`ldd $prog | awk '{ print $3 }' | grep -v \(`
echo $LIBS
for l in $LIBS; do
#mkdir -p ./`dirname $l` > /dev/null 2>&1
cp $l ./ --parents
done
fi
done
popd
# change root
chroot /tmp/chroot /bin/bash
Code: Select all
chroot: can't execute '/bin/bash': No such file or directory
Anyone got much experience with chroot that might help?
Cheers,
Jim