]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Add support to "gshred" and "rm -P" to safely delete a file
authorGrégoire Jadi <gjadi@omecha.info>
Sun, 25 Feb 2018 15:09:10 +0000 (16:09 +0100)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 30 May 2018 15:57:46 +0000 (12:57 -0300)
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.

lib/keyringer/functions

index 6f9a5e3ac6831f7f16a2f72cda6f50a0c8f20139..6fc82e71ccd6281d7350124b0239815fc9a7c36e 100755 (executable)
@@ -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"