From 78a56a4d7b7d74ded10436f9d1e972cc47807cab Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 30 Jun 2014 14:44:04 +0200 Subject: tmpdir: more cross platform solution, and .txt file ending --- src/password-store.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 575371a..38dce6c 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -168,7 +168,7 @@ tmpdir() { [[ $1 == "nowarn" ]] && warn=0 local template="$PROGRAM.XXXXXXXXXXXXX" if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then - SECURE_TMPDIR="$(TMPDIR=/dev/shm mktemp -d -t "$template")" + SECURE_TMPDIR="$(mktemp -d "/dev/shm/$template")" remove_tmpfile() { rm -rf "$SECURE_TMPDIR" } @@ -182,7 +182,7 @@ tmpdir() { Are you sure you would like to continue? _EOF )" - SECURE_TMPDIR="$(mktemp -d -t "$template")" + SECURE_TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/$template")" shred_tmpfile() { find "$SECURE_TMPDIR" -type f -exec $SHRED {} + rm -rf "$SECURE_TMPDIR" @@ -419,10 +419,9 @@ cmd_edit() { mkdir -p -v "$PREFIX/$(dirname "$path")" set_gpg_recipients "$(dirname "$path")" local passfile="$PREFIX/$path.gpg" - local template="$PROGRAM.XXXXXXXXXXXXX" tmpdir #Defines $SECURE_TMPDIR - local tmp_file="$(TMPDIR="$SECURE_TMPDIR" mktemp -t "$template")" + local tmp_file="$(mktemp "$SECURE_TMPDIR/XXXXXXXXXXXXX.txt")" local action="Add" -- cgit v1.2.3-59-g8ed1b