summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2019-01-19 00:12:11 +0000
committerBen Hutchings <ben@decadent.org.uk>2019-01-20 01:31:59 +0000
commit66998b7313799c175583d2fbe524f6f9d46943a7 (patch)
tree1d3c4c712fe92480ecfa494adb2ab4cd90dadd9b
parentdc9d23d12f7b0e0adb78db0aa70bb3f65a25164d (diff)
downloadklibc-maint-66998b7313799c175583d2fbe524f6f9d46943a7.tar.gz
newklibc: Use a securely-created temporary directory
Don't hardcode directory names in /tmp. Use mktemp -d to create a temporary directory and put everything under that.
-rwxr-xr-xnewklibc12
1 files changed, 3 insertions, 9 deletions
diff --git a/newklibc b/newklibc
index 58af7f9..b03d4d1 100755
--- a/newklibc
+++ b/newklibc
@@ -10,11 +10,8 @@ git_export () {
git archive --format=tar "$2" | tar -C "$1" -xf -
}
-me=`whoami`
-here=/tmp/"$USER"/klibc.tmp
-mkdir -p $here
+here="$(mktemp -d)"
cd $here
-rm -rf klibc*
if [ x"$1" = x'test' ]; then
real=false
@@ -33,10 +30,7 @@ releasedir=/home/hpa/klibc/release/
GIT_DIR="$repo" git fetch -f
# Get a snapshot of the top of the repository
-tmpdir=/tmp/$me/klibc.$$
-rm -rf "$tmpdir"
-mkdir -p "$tmpdir"
-gitdir="$tmpdir"/git
+gitdir="$here"/git
git clone -s -l "$repo" "$gitdir"
cd "$gitdir"
@@ -55,7 +49,7 @@ if $real; then
git tag -u "$signkey" -f -m "Relased on $now" "$tag"
fi
-exportdir="$tmpdir"/"$tag"
+exportdir="$here"/"$tag"
rm -rf "$exportdir"
git_export "$exportdir" HEAD