From d32faa9d6cddbc714de708ecc052b43b49d7faa8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 18 Sep 2010 13:50:04 -0300 Subject: Fixing tmpfile handling --- lib/keyringer/functions | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3