aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keyringer/functions')
-rwxr-xr-xlib/keyringer/functions17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 6f9a5e3..d529daf 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -161,7 +161,7 @@ function keyringer_set_tmpfile {
if [ -z "$1" ]; then
template="$tmp/keyringer.XXXXXXXXXX"
else
- template="$tmp/XXXXXXXXXX.$1"
+ template="$tmp/keyringer.$1.XXXXXXXXXX"
fi
mkdir -p "$tmp"
@@ -192,27 +192,36 @@ function keyringer_shred {
return
fi
+ # Create our test target
+ local rmtest="$(mktemp)"
+
# Get shred implementation
if which wipe &> /dev/null; then
tool="wipe"
elif which shred &> /dev/null; then
tool="shred"
+ elif rm -P "${rmtest}" &> /dev/null; then
+ tool="rm -P"
else
# Worst implementation
message="WARNING $message"
tool="rm"
fi
+ # Cleanup in case "rm -P" is never called or -P flag is unsupported
+ rm -f "${rmtest}"
+
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 {} \;
+ find $path -type f -exec $tool -uf {} \;
+ find $path -depth -type d -exec rmdir {} \;
fi
else
- if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ]; then
+ if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ] || [ "$tool" == "rm -P" ]; then
$tool -f "$path"
else
$tool -uf "$path"