summaryrefslogtreecommitdiff
path: root/src/password-store.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-06-29 10:45:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-06-29 10:47:22 +0200
commitf847dfb10b01bbe5f53c3d66badedfc1be9e9046 (patch)
treeea35343eaea356ee9fb5c1e37dbc7ecfa68b4dcd /src/password-store.sh
parent9ed79aacd5ef54b9f19f0b91c000f13f46ec76ab (diff)
downloadpass-f847dfb10b01bbe5f53c3d66badedfc1be9e9046.tar.gz
pass-f847dfb10b01bbe5f53c3d66badedfc1be9e9046.tar.bz2
pass-f847dfb10b01bbe5f53c3d66badedfc1be9e9046.zip
darwin: properly ejects ramdisks
In the move away from extensive global variables and improved cleanup routines, we forgot to fix the darwin platform file, which means temporary ramdisks never got unmounted. This patch cleans up the general cleanup trap logic routines.
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 8c6c9c5..dfd59fe 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -163,11 +163,16 @@ clip() {
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
tmpdir() {
+ [[ -n $SECURE_TMPDIR ]] && return
local warn=1
[[ $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")"
+ remove_tmpfile() {
+ rm -rf "$SECURE_TMPDIR"
+ }
+ trap remove_tmpfile INT TERM EXIT
else
[[ $warn -eq 1 ]] && yesno "$(cat <<-_EOF
Your system does not have /dev/shm, which means that it may
@@ -178,6 +183,11 @@ tmpdir() {
_EOF
)"
SECURE_TMPDIR="$(mktemp -d -t "$template")"
+ shred_tmpfile() {
+ find "$SECURE_TMPDIR" -type f -exec $SHRED {} +
+ rm -rf "$SECURE_TMPDIR"
+ }
+ trap shred_tmpfile INT TERM EXIT
fi
}
@@ -413,11 +423,6 @@ cmd_edit() {
tmpdir #Defines $SECURE_TMPDIR
local tmp_file="$(TMPDIR="$SECURE_TMPDIR" mktemp -t "$template")"
- eval "shred_tmpfile() {
- $SHRED '$tmp_file'
- rm -rf '$SECURE_TMPDIR' '$tmp_file'
- }"
- trap shred_tmpfile INT TERM EXIT
local action="Add"