t[cleanup] Privatize {,_}endgame event - tomb - the crypto undertaker
HTML git clone git://parazyd.org/tomb.git
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit b0538983000b6c6f23fee119a0b900a4a7a7746c
DIR parent 8e38a1c31b65582edd48647d42a825f48eaeeabb
HTML Author: hellekin <hellekin@cepheide.org>
Date: Thu, 23 Oct 2014 03:58:35 -0300
t[cleanup] Privatize {,_}endgame event
Diffstat:
M tomb | 40 +++++++++++++++++--------------
1 file changed, 22 insertions(+), 18 deletions(-)
---
DIR diff --git a/tomb b/tomb
t@@ -97,14 +97,16 @@ export TEXTDOMAIN=tomb
# {{{ Safety functions
-endgame() {
- # here clear all temp files and flush all pipes
+# Cleanup anything sensitive before exiting.
+_endgame() {
- # prepare some random material to overwrite vars
- rr="$RANDOM"
+ # Prepare some random material to overwrite vars
+ local rr="$RANDOM"
while [[ ${#rr} -lt 500 ]]; do
- rr+="$RANDOM"; done
- # we make sure no info is left in unallocated mem
+ rr+="$RANDOM"
+ done
+
+ # Ensure no information is left in unallocated memory
TOMBPATH="$rr"; unset TOMBPATH
TOMBDIR="$rr"; unset TOMBDIR
TOMBFILE="$rr"; unset TOMBFILE
t@@ -115,24 +117,26 @@ endgame() {
TOMBPASSWORD="$rr"; unset TOMBPASSWORD
for f in $TOMBTMPFILES; do
- ${=WIPE} "$f"; done
+ ${=WIPE} "$f"
+ done
unset TOMBTMPFILES
for l in $TOMBLOOPDEVS; do
- losetup -d "$l"; done
+ losetup -d "$l"
+ done
unset TOMBLOOPDEVS
}
-# trap functions for the endgame event
-TRAPINT() { endgame INT }
-TRAPEXIT() { endgame EXIT }
-TRAPHUP() { endgame HUP }
-TRAPQUIT() { endgame QUIT }
-TRAPABRT() { endgame ABORT }
-TRAPKILL() { endgame KILL }
-TRAPPIPE() { endgame PIPE }
-TRAPTERM() { endgame TERM }
-TRAPSTOP() { endgame STOP }
+# Trap functions for the _endgame event
+TRAPINT() { _endgame INT }
+TRAPEXIT() { _endgame EXIT }
+TRAPHUP() { _endgame HUP }
+TRAPQUIT() { _endgame QUIT }
+TRAPABRT() { _endgame ABORT }
+TRAPKILL() { _endgame KILL }
+TRAPPIPE() { _endgame PIPE }
+TRAPTERM() { _endgame TERM }
+TRAPSTOP() { _endgame STOP }
check_shm() {
# TODO: configure which tmp dir to use from a cli flag