diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-11-14 15:01:01 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-11-14 15:01:01 -0200 |
commit | 6c08cb89106d0ab22749993ef860f593bb60b344 (patch) | |
tree | 24f6bedea9892b707eee73f417a2691f738891ee /lib | |
parent | 4f05749d3bec1ce121372dbaa7eccdaa0dc4b5ab (diff) | |
download | keyringer-6c08cb89106d0ab22749993ef860f593bb60b344.tar.gz keyringer-6c08cb89106d0ab22749993ef860f593bb60b344.tar.bz2 |
Adding keyringer_shred (closes #27)
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/keyringer/functions | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 40e13aa..fcec045 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -144,13 +144,42 @@ function keyringer_set_tmpfile { trap "keyringer_unset_tmpfile $TMPWORK; exit" INT TERM EXIT } +# Shred files +function keyringer_shred { + local path="$1" + local tool + + if [ -z "$path" ]; then + return + fi + + # Get shred implementation + if which wipe &> /dev/null; then + tool="wipe" + elif which shred &> /dev/null; then + tool="shred" + else + # Worst implementation + tool="rm" + fi + + echo "Removing $path using $tool..." + + if [ -d "$path" ]; then + find $path -exec $tool -f {} \; + rmdir $path + elif [ -e "$path" ]; then + $tool -f "$path" + fi +} + # Remove a temporary file function keyringer_unset_tmpfile { if [ -z "$1" ]; then echo "No tmp file set" fi - rm -f "$1" + keyringer_shred "$1" if [ "$?" != "0" ]; then echo "Warning: could not delete file $1. Please delete it manually as it might have sensitive information." |