From: Marc Fiuczynski Date: Wed, 17 Nov 2004 19:35:47 +0000 (+0000) Subject: PL2445 X-Git-Tag: after-util-vserver-0_30_208-revert~208 X-Git-Url: http://git.onelab.eu/?p=util-vserver.git;a=commitdiff_plain;h=745da7fd414303936df07cf6744a858e13794e85 PL2445 - Reverted to using "du -s" rather than "du -b -s". Note that after several cases where the said test failed on a particular PlanetLab production machine, I can no longer cause the failure with "du -b -s". This indicates that there is something odd going on with vbuild and/or the underlying filesystem. - Fix exit code bug. When the du size test fails, vuseradd will now exit with a non-zero code. This way node manager wont think the /vservers/$NAME vserver was created, eventhough it was not. - Removing slice account from /etc/passwd upon vbuild or "du" error. --- diff --git a/scripts/vuseradd b/scripts/vuseradd index 36a0f95..af4c467 100755 --- a/scripts/vuseradd +++ b/scripts/vuseradd @@ -4,7 +4,7 @@ # # Copyright (c) 2004 The Trustees of Princeton University (Trustees). # -# $Id: vuseradd,v 1.15 2004/11/06 16:10:42 mlhuang Exp $ +# $Id: vuseradd,v 1.16 2004/11/12 18:44:09 mef Exp $ # : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars} @@ -54,14 +54,24 @@ if [ ! -d "$VROOTDIR/$NAME" ] ; then "$PKGLIBDIR/vbuild" "$VROOTDIR/vserver-reference" "$TMP" RETVAL=$? # move it to .vcache when complete - if [ $RETVAL -ne 0 ] || \ - [ $(du -b -s "$TMP" | awk "{ print \$1 }") -lt \ - $(du -b -s "$VROOTDIR/vserver-reference" | awk "{ print \$1 }") ] ; then + if [ $RETVAL -ne 0 ] ; then echo "Error $RETVAL building $VROOTDIR/$NAME" chattr -R -i "$TMP" rm -rf "$TMP" + userdel $NAME exit $RETVAL else + # sanity check + vnewsize=$(du -s "$TMP" | awk "{ print \$1 }") + vrefsize=$(du -s "$VROOTDIR/vserver-reference" | awk "{ print \$1 }") + if [ $vnewsize -lt $vrefsize ] ; then + echo "Error 'du -s $VROOTDIR/$NAME'=$vnewsize < 'du -s $VROOTDIR/vserver-reference'=$vrefsize" + chattr -R -i "$TMP" + rm -rf "$TMP" + userdel $NAME + exit 256 + fi + mv "$TMP" "$VROOTDIR/$NAME" fi fi