diff --git a/lib/common.sh b/lib/common.sh
index e826e9700a4fef90e692a8c5e3668a618a2589b1..6bbf6dee07b76e488a61090d101b14cc12e7c16c 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -58,7 +58,7 @@ stat_done() {
 }
 
 setup_workdir() {
-	[[ -z $WORKDIR ]] && WORKDIR=$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)
+	[[ -z $WORKDIR ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
 }
 
 cleanup() {