aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-09-18 13:50:04 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-09-18 13:50:04 -0300
commitd32faa9d6cddbc714de708ecc052b43b49d7faa8 (patch)
tree4572b4fd1509531c0b0ec013d0eccaaff8412c00 /lib
parent43235df8406f6e8e400de502d36b9fa46de12756 (diff)
downloadkeyringer-d32faa9d6cddbc714de708ecc052b43b49d7faa8.tar.gz
keyringer-d32faa9d6cddbc714de708ecc052b43b49d7faa8.tar.bz2
Fixing tmpfile handling
Diffstat (limited to 'lib')
-rw-r--r--lib/keyringer/functions13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index a2a35be..13502f7 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -122,14 +122,18 @@ function keyringer_set_tmpfile {
mkdir -p $BASEDIR/tmp
keyringer_git_ignore 'tmp/*'
- tmpfile="`mktemp $template`"
+ if [ "$2" == "-d" ]; then
+ TMPWORK="`mktemp -d $template`"
+ else
+ TMPWORK="`mktemp $template`"
+ fi
if [ "$?" != "0" ]; then
- echo "Error: can't set tmpfile $tmpfile"
+ echo "Error: can't set TMPWORK $TMPWORK"
exit 1
fi
- echo $tmpfile
+ trap "keyringer_unset_tmpfile $TMPWORK; exit" INT TERM EXIT
}
# Remove a temporary file
@@ -191,6 +195,9 @@ function keyringer_set_env {
echo "No option config was found"
exit 1
fi
+
+ # Ensure that keydir exists
+ mkdir -p $KEYDIR && chmod 700 $KEYDIR
}
# Get a file argument