From 418aaff8037f39b465d53730407d75c67a89135e Mon Sep 17 00:00:00 2001 From: zacheiss Date: Tue, 19 Mar 2002 22:07:06 +0000 Subject: [PATCH] Unpack tarfile in a temporary directory to avoid changing the permissions of the directory we unpack into. --- gen/ip-billing.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/gen/ip-billing.sh b/gen/ip-billing.sh index afba3bb4..ae6acd5f 100755 --- a/gen/ip-billing.sh +++ b/gen/ip-billing.sh @@ -1,7 +1,6 @@ #!/bin/sh # -# $Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/stel -lar.sh,v 1.1 2002/01/18 06:54:45 zacheiss Exp $ +# $Header$ PATH=/usr/bin:/bin:/usr/sbin:/sbin @@ -15,17 +14,32 @@ fi # error codes the library uses: MR_MISSINGFILE=47836473 MR_TARERR=47836476 +MR_MKCRED=47836474 OUTFILE=/var/tmp/ip-billing.out +OUTDIR=/var/tmp/ip-billing.dir # Alert if the output file doesn't exist test -r $OUTFILE || exit $MR_MISSINGFILE +# Make a temporary directory to unpack files into. +rm -rf $OUTDIR +mkdir $OUTDIR || exit $MR_MKCRED +cd $OUTDIR || exit $MR_MKCRED + # unpack the file -(cd /var/tmp && tar xf $OUTFILE) || exit $MR_TARERR +tar xpf $OUTFILE || exit $MR_TARERR +for i in ctl dat; do + if [ ! -f moira.$i ]; then + exit $MR_MISSINGFILE + fi + mv moira.$i /var/tmp +done # cleanup -rm -f $OUTFILE +cd / +rm -rf $OUTDIR +test -f $OUTFILE && rm -f $OUTFILE test -f $0 && rm -f $0 exit 0 -- 2.45.2