summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-09-13 00:50:25 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-09-13 00:50:25 +0200
commit59b5377ab155e0a00f57287d8b55ca5b05f0974e (patch)
treec24bd2a6986418413bfd0ebe98eb366c5755fc19
parent2ac8b6577f806b8bd4cbc103d2837ebed68f6778 (diff)
downloadpass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.tar.gz
pass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.tar.bz2
pass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.zip
Be more careful about cleaning up.
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index f9e13e4..ed86248 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -212,7 +212,9 @@ case "$command" in
passfile="$PREFIX/$path.gpg"
template="$program.XXXXXXXXXXXXX"
- if [ -d /dev/shm -a -w /dev/shm -a -x /dev/shm ]; then
+ trap 'rm -rf "$tmp_dir" "$tmp_file"' INT TERM EXIT
+
+ if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then
tmp_dir="$(TMPDIR=/dev/shm mktemp -t $template -d)"
else
echo "Your system does not have /dev/shm, which means that it may"
@@ -229,10 +231,7 @@ case "$command" in
action="Added"
if [[ -f $passfile ]]; then
- if ! gpg -q -d -o "$tmp_file" --yes "$passfile"; then
- rm -rf "$tmp_file" "$tmp_dir"
- exit 1
- fi
+ gpg -q -d -o "$tmp_file" --yes "$passfile" || exit 1
action="Edited"
fi
${EDITOR:-vi} "$tmp_file"
@@ -240,7 +239,6 @@ case "$command" in
echo "GPG encryption failed. Retrying."
sleep 1
done
- rm -rf "$tmp_file" "$tmp_dir"
if [[ -d $GIT ]]; then
git add "$passfile"
>-1/+1 2007-07-30updatesnecoro1-1/+1 2007-07-30updatesnecoro2-21/+64 2007-07-28some more pause emerge itemsnecoro5-276/+423 2007-07-27changed design / added linknecoro3-66/+154 2007-07-26changed design / added linknecoro2-34/+27 2007-07-25changed design / added linknecoro5-86/+188 2007-07-24made the resume_loop-plugin change titles toonecoro5-7/+22 2007-07-21added logviewersnecoro7-215/+429 2007-07-21updated howtonecoro1-14/+24 2007-07-20new Plugin Schemenecoro1-5/+4 2007-07-20new Plugin Schemenecoro1-1/+1 2007-07-20new Plugin Schemenecoro9-162/+214 2007-07-13fixesnecoro4-27/+37 2007-07-13new fancier log outputnecoro14-127/+116 2007-07-11added SIGSTOP/SIGCONT support; SIGTERM now works ;)necoro8-208/+275 2007-07-09bug in shutdown pluginnecoro2-5/+12 2007-07-09added resume_loop pluginnecoro1-1/+1 2007-07-09added resume_loop pluginnecoro10-22/+162 2007-07-07some more documentationnecoro6-4/+108 2007-07-07Some documentation worknecoro7-18/+129