1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/bin/sh
#
#
#
KEEP="/dev/log
"
if [ Q$1 == "Q" -o Q$2 == "Q" ]
then
echo "Usage: upratejail <config.file> <jail identifier>"
else
JAIL=`cat $1 | grep Root: | grep $2 | awk '{print $2}'`
echo "jail: " $JAIL
echo "config: " $1
read
if test -d $JAIL
then
cd $JAIL
tmpfile=`tempfile` || { echo "$0: Cannot create temporary file" >&2; exit 1; }
tmpfile2=`tempfile` || { echo "$0: Cannot create temporary file" >&2; exit 1; }
trap " /bin/rm -f -- \"$tmpfile\" \"$tmpfile2\"" 0 1 2 3 13 15
find $JAIL -type b > $tmpfile
find $JAIL -type c >> $tmpfile
find $JAIL -type p >> $tmpfile
find $JAIL -type f >> $tmpfile
find $JAIL -type l >> $tmpfile
find $JAIL -type s >> $tmpfile
for i in `echo $KEEP`
do
cat $tmpfile | grep -v $JAIL$i > $tmpfile2
mv $tmpfile2 $tmpfile
done
for i in `cat $tmpfile`
do
rm $i
done
cat $tmpfile | xargs -r rm
/usr/sbin/jailer $1 $2
else
echo "This jail does not exist!"
fi
fi
|