diff options
author | Grégoire Jadi <gjadi@omecha.info> | 2018-02-25 16:09:10 +0100 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-05-30 12:57:46 -0300 |
commit | 299cdf52679f17dee6a61a0da3e4cfd7e1a39808 (patch) | |
tree | f77130bddb3fca68163d7b3d0d47c015e15ba82b | |
parent | 86bf9686290793073e7d1e4af5f46290175ef6b6 (diff) | |
download | keyringer-299cdf52679f17dee6a61a0da3e4cfd7e1a39808.tar.gz keyringer-299cdf52679f17dee6a61a0da3e4cfd7e1a39808.tar.bz2 |
Add support to "gshred" and "rm -P" to safely delete a file
gshred(1) is shred(1) from GNU coreutils on OpenBSD
rm(1) on OpenBSD
-P Overwrite regular files before deleting them. Files are
overwritten once with a random pattern. Files with multiple
links will be unlinked but not overwritten.
-rwxr-xr-x | lib/keyringer/functions | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 6f9a5e3..6fc82e7 100755 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -197,6 +197,10 @@ function keyringer_shred { tool="wipe" elif which shred &> /dev/null; then tool="shred" + elif which gshred &> /dev/null; then + tool="gshred" + elif _F=$(mktemp); rm -P "${_F}" &> /dev/null; then + tool="rm -P" else # Worst implementation message="WARNING $message" @@ -206,13 +210,13 @@ function keyringer_shred { echo "$message $path using $tool..." if [ -d "$path" ]; then - if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ]; then + if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ] || [ "$tool" == "rm -P" ]; then $tool -rf $path else find $path -exec $tool -uf {} \; fi else - if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ]; then + if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ] || [ "$tool" == "rm -P" ]; then $tool -f "$path" else $tool -uf "$path" |