aboutsummaryrefslogtreecommitdiffstatshomepage
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
parentAllow options in EDITOR variable (diff)
downloadpassword-store-f847dfb10b01bbe5f53c3d66badedfc1be9e9046.tar.xz
password-store-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 'src/password-store.sh')
-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"