Needs to be removed again.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/l2chroot Sun Jan 09 16:22:27 2011 +0100
1.3 @@ -0,0 +1,47 @@
1.4 +#!/bin/bash
1.5 +# Use this script to copy shared (libs) files to Apache/Lighttpd chrooted
1.6 +# jail server.
1.7 +# ----------------------------------------------------------------------------
1.8 +# Written by nixCraft <http://www.cyberciti.biz/tips/>
1.9 +# (c) 2006 nixCraft under GNU GPL v2.0+
1.10 +# + Added ld-linux support
1.11 +# + Added error checking support
1.12 +# ------------------------------------------------------------------------------
1.13 +# See url for usage:
1.14 +# http://www.cyberciti.biz/tips/howto-setup-lighttpd-php-mysql-chrooted-jail.html
1.15 +# -------------------------------------------------------------------------------
1.16 +# Set CHROOT directory name
1.17 +BASE="/webroot"
1.18 +
1.19 +if [ $# -eq 0 ]; then
1.20 + echo "Syntax : $0 /path/to/executable"
1.21 + echo "Example: $0 /usr/bin/php5-cgi"
1.22 + exit 1
1.23 +fi
1.24 +
1.25 +[ ! -d $BASE ] && mkdir -p $BASE || :
1.26 +
1.27 +# iggy ld-linux* file as it is not shared one
1.28 +FILES="$(ldd $1 | awk '{ print $3 }' |egrep -v ^'\(')"
1.29 +
1.30 +echo "Copying shared files/libs to $BASE..."
1.31 +for i in $FILES
1.32 +do
1.33 + d="$(dirname $i)"
1.34 + [ ! -d $BASE$d ] && mkdir -p $BASE$d || :
1.35 + /bin/cp $i $BASE$d
1.36 +done
1.37 +
1.38 +# copy /lib/ld-linux* or /lib64/ld-linux* to $BASE/$sldlsubdir
1.39 +# get ld-linux full file location
1.40 +sldl="$(ldd $1 | grep 'ld-linux' | awk '{ print $1}')"
1.41 +# now get sub-dir
1.42 +sldlsubdir="$(dirname $sldl)"
1.43 +
1.44 +if [ ! -f $BASE$sldl ];
1.45 +then
1.46 + echo "Copying $sldl $BASE$sldlsubdir..."
1.47 + /bin/cp $sldl $BASE$sldlsubdir
1.48 +else
1.49 + :
1.50 +fi