1
# This program is copyright 2011 Percona Inc.
2
# Feedback and improvements are welcome.
4
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
5
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
6
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
8
# This program is free software; you can redistribute it and/or modify it under
9
# the terms of the GNU General Public License as published by the Free Software
10
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
11
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16
# Place, Suite 330, Boston, MA 02111-1307 USA.
17
# ###########################################################################
19
# ###########################################################################
22
# tmpdir make a secure temporary directory using mktemp.
30
# Create a secure tmpdir and set TMPDIR.
33
# dir - User-specified tmpdir (default none).
35
# Set Global Variables:
36
# TMPDIR - Absolute path of secure temp directory.
40
if [ -n "$dir" ]; then
41
if [ ! -d "$dir" ]; then
42
mkdir $dir || die "Cannot make tmpdir $dir"
46
local tool=`basename $0`
48
TMPDIR=`mktemp -d /tmp/${tool}.${pid}.XXXXX` \
49
|| die "Cannot make secure tmpdir"
54
# Remove the tmpdir and unset TMPDIR.
56
# Optional Global Variables:
57
# TMPDIR - TMPDIR set by <mk_tmpdir()>.
59
# Set Global Variables:
62
if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
68
# ###########################################################################
70
# ###########################################################################