Package: jailer Version: 0.4-9 Severity: normal Tags: patch As subject line. Since updatejail is normally run as root, this can be a bit of an unfortunate side effect of what would otherwise be a trivial accident !
Attached is a patch which fixes the issue, as well as adding other safety and efficiency fixes such as fewer 'find's and clearer prompts/errors. More could undoubtedly be done but I feel this will do for now ! -- System Information: Debian Release: 4.0 APT prefers stable APT policy: (600, 'stable'), (480, 'proposed-updates'), (80, 'testing'), (3, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.18-6-k7 Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Versions of packages jailer depends on: ii cpio 2.6-18.1+etch1 GNU cpio -- a program to manage ar ii perl [perl5] 5.8.8-7etch3 Larry Wall's Practical Extraction jailer recommends no packages. -- no debconf information
--- updatejail.orig 2006-11-03 02:07:10.000000000 +0000 +++ updatejail 2008-05-29 22:48:48.000000000 +0100 @@ -7,39 +7,47 @@ " -if [ Q$1 == "Q" -o Q$2 == "Q" ] +if [ "Q$1" == "Q" -o "Q$2" == "Q" ] then - echo "Usage: upratejail <config.file> <jail identifier>" + echo "Usage: updatejail <config.file> <jail identifier>" else - JAIL=`cat $1 | grep Root: | grep $2 | awk '{print $2}'` - echo "jail: " $JAIL + if [ ! -f "$1" ]; then + echo "$1: file not found" + exit 1 + fi + JAIL=`cat "$1" | grep Root: | grep "$2" | awk '{print $2}'` + echo "jail: $JAIL" echo "config: " $1 - read + read -p "Press ENTER to continue" + + echo "$KEEP" > /tmp/$$.updatejail.keep - - if test -d $JAIL + if test -d "$JAIL" then - cd $JAIL + set -e + + cd "$JAIL" + + find "$JAIL" \( -type b \ + -o -type c \ + -o -type p \ + -o -type f \ + -o -type l \ + -o -type s \) -print > /tmp/$$.updatejail - find $JAIL -type b > /tmp/$$.updatejail - find $JAIL -type c >> /tmp/$$.updatejail - find $JAIL -type p >> /tmp/$$.updatejail - find $JAIL -type f >> /tmp/$$.updatejail - find $JAIL -type l >> /tmp/$$.updatejail - find $JAIL -type s >> /tmp/$$.updatejail for i in `echo $KEEP` do - cat /tmp/$$.updatejail | grep -v $JAIL$i > /tmp/$$.updatejail.tmp + grep -v "^$JAIL$i\$" /tmp/$$.updatejail > /tmp/$$.updatejail.tmp mv /tmp/$$.updatejail.tmp /tmp/$$.updatejail done - for i in `cat /tmp/$$.updatejail` - do - rm $i - done + + cat /tmp/$$.updatejail | xargs -r rm + rm /tmp/$$.updatejail - /usr/sbin/jailer $1 $2 + + /usr/sbin/jailer "$1" "$2" else - echo "This jail does not exist!" + echo "Jail directory '$JAIL' does not exist!" fi fi