Update of /cvsroot/devil-linux/build/config/etc/init.d
In directory sc8-pr-cvs1:/tmp/cvs-serv26226/config/etc/init.d
Modified Files:
Tag: rel-1-0-patches
jail
Log Message:
backported some changes
- jail script has new command DELETE
- domino jail script now empties the lib and etc directories before creating
the jail
- fixed the corner case when an empty directory is being copied to the jail
dir (fl)
- postfix jail script now empties the lib and etc directories before
creating the jail
- better handling of subdirectories & links in jail script (fl)
Index: jail
===================================================================
RCS file: /cvsroot/devil-linux/build/config/etc/init.d/jail,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -d -r1.21.2.1 -r1.21.2.2
--- jail 20 Dec 2003 18:59:39 -0000 1.21.2.1
+++ jail 26 Dec 2003 14:45:57 -0000 1.21.2.2
@@ -74,25 +74,39 @@
ls -l $1 | cut -d ">" -f 2 | cut -c 2-
}
-# copies the files given in $1 to $2
+# copies the files given in $1 to $JAILDIR
# preserve attributes
# if file is a link follow this and copy all necessary links/files
#
function copy_files_links()
{
FILES=$1
- [ -d "$FILES" ] && FILES=$FILES/*
- for FILE in $(ls -d $FILES)
+ if [ -d "$FILES" ]; then
+ mkdir -p $JAILDIR/$FILES
+ chown -f --reference=$FILES $JAILDIR/$FILES
+ FILES=$FILES/*
+ fi
+
+ for FILE in $(ls -d $FILES 2>/dev/null)
do
- TARGETDIR=${FILE%/*}
- FILE=$FILE
- mkdir -p $JAILDIR$TARGETDIR
- cp -dfpR $FILE $JAILDIR$TARGETDIR
- if [ -L "$FILE" ]; then
- LINK=$(read_link $FILE)
- LINKDIR=${LINK%/*}
- [ "$LINKDIR" = "$LINK" ] && LINK=$TARGETDIR/$LINK
- copy_files_links $LINK
+ if [ -d "$FILE" ]; then
+ # a subdirectory found
+ copy_files_links $FILE
+ else
+ # a file or symlink found
+ TARGETDIR=${FILE%/*}
+ if [ ! -d $JAILDIR/$TARGETDIR ]; then
+ # in case $1 contained only a file we have to create the directory
+ mkdir -p $JAILDIR/$TARGETDIR
+ chown -f --reference=$TARGETDIR $JAILDIR/$TARGETDIR
+ fi
+ cp -dfpR $FILE $JAILDIR/$TARGETDIR
+ if [ -L "$FILE" ]; then
+ LINK=$(read_link $FILE)
+ LINKDIR=${LINK%/*}
+ [ "$LINKDIR" = "$LINK" ] && LINK=$TARGETDIR/$LINK
+ copy_files_links $LINK
+ fi
fi
done
}
@@ -165,6 +179,9 @@
CAP )
[ -z "$JCAPS" ] && CAPS="--cap"
CAPS=$CAPS" "$PARAM
+ ;;
+ DELETE )
+ rm -rf $JAILDIR$PARAM
;;
USER )
USER="--user "$PARAM
|