use mktemp from coreutils instead of homegrown tempdir creation

This commit is contained in:
Joel Beckmeyer 2021-11-30 08:37:07 -05:00
parent d4e87dabdb
commit fd386dbeda

View File

@ -12,16 +12,8 @@ fi
set -Eeuo pipefail
destfile_pfx="$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32)" || true
tempdir="$(mktemp -d)"
while [ -d "/tmp/doasedit/$destfile_pfx" ]; do
destfile_pfx="$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32)"
done
tempdir="/tmp/doasedit/$destfile_pfx"
# we don't want any other users to be able to read what we're doing, so -m700
mkdir -m700 -p $tempdir
trap "rm -rf $tempdir" EXIT
srcfile="$(doas realpath $1)"