Secure /tmp usage for bash scripting
I’ll cut to the chase…
# Secure tmp directory usage.
tmp=${TMPDIR-/tmp}
tmp=$tmp/unf.$RANDOM.$RANDOM.$RANDOM.$$
(umask 077 && mkdir $tmp) || {
echo “Could not create temporary directory! Exiting.” 1>&2
exit 1
}
(umask 077 && mkdir $tmp/mebad) || {
echo “Could not create temporary directory! Exiting.” 1>&2
exit 1
}

April 24th, 2008 at 2:22 pm
I think you mean “/bin/mktemp”
April 25th, 2008 at 10:50 am
You’re right. I do. Thanks for the tip.