From bb9f8584c312b5bc641430adfeda68b80c58e5d5 Mon Sep 17 00:00:00 2001 From: Graham Lyons Date: Fri, 10 Mar 2017 13:20:43 +0000 Subject: [PATCH] Use the `rm` command with `-P` as a shred fallback (#179) * Use the `rm` command with `-P` as a shred fallback The newer versions of OSX (Sierra) have neither `shred` nor `srm`. They do have `rm` with the `-P` option, so we can fall back to that before resorting to plain old `rm`. * Add double-quotes and braces to the shell variable. We should treat the variable as a string, and we should also be safe when interpolating it. --- bin/_blackbox_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index 46447bf..6ff377a 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -312,6 +312,9 @@ function shred_file() { #NOTE: srm by default uses 35-pass Gutmann algorithm CMD=srm OPT=-f + elif _F=$(mktemp); rm -P "${_F}" >/dev/null 2>/dev/null ; then + CMD=rm + OPT=-Pf else echo "shred_file: WARNING: No secure deletion utility (shred or srm) present; using insecure rm" CMD=rm