tomb

the crypto undertaker
git clone git://parazyd.org/tomb.git
Log | Files | Refs | README | LICENSE

commit 5b7f875f3d92ae13b7cc2570f4cc08d7c30f2a87
parent 1f852908ae669cabcce0c3206baea33bb10c1ee3
Author: Jaromil <jaromil@dyne.org>
Date:   Mon,  6 Feb 2017 11:52:08 +0100

Merge pull request #243 from Narrat/bug/slam

Use of lsof to fix slam for specific mountpoint
Diffstat:
MINSTALL.md | 1+
Mdoc/tomb.1 | 6+++---
Mdoc/tomb_manpage.pdf | 0
Mtomb | 17++++++++++++-----
4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/INSTALL.md b/INSTALL.md @@ -66,6 +66,7 @@ Tomb can use some optional tools to extend its functionalities: executable | function ---------- | --------------------------------------------------- + lsof | slam a tomb (close even if open programs) dcfldd | show progress while digging tombs and keys steghide | bury and exhume keys inside images resizefs | extend the size of existing tomb volumes diff --git a/doc/tomb.1 b/doc/tomb.1 @@ -1,4 +1,4 @@ -.TH tomb 1 "November 26, 2014" "tomb" +.TH tomb 1 "February 05, 2017" "tomb" .SH NAME Tomb \- the Crypto Undertaker @@ -111,9 +111,9 @@ the tomb is in use by running processes (to force close, see .IP "slam" Closes a tomb like the command \fIclose\fR does, but it doesn't fail even if the tomb is in use by other application processes: it looks -for and violently kills \-9 each of them. This command may +for and closes each of them (in order: TERM, HUP, KILL). This command may provoke unsaved data loss, but assists users to face surprise -situations. +situations. It requires \fIlsof\fR else it falls back to \fIclose\fR. .B diff --git a/doc/tomb_manpage.pdf b/doc/tomb_manpage.pdf Binary files differ. diff --git a/tomb b/tomb @@ -809,6 +809,8 @@ _ensure_dependencies() { # Which wipe command to use command -v wipe 1>/dev/null 2>/dev/null && WIPE=(wipe -f -s) + # Check for lsof for slamming tombs + command -v lsof -h 1>/dev/null 2>/dev/null || LSOF=0 # Check for steghide command -v steghide 1>/dev/null 2>/dev/null || STEGHIDE=0 # Check for resize @@ -2506,20 +2508,20 @@ umount_tomb() { # Kill all processes using the tomb slam_tomb() { # $1 = tomb mount point - if [[ -z `fuser -m "$1" 2>/dev/null` ]]; then + if [[ -z `lsof -t +D "$1" 2>/dev/null` ]]; then return 0 fi #Note: shells are NOT killed by INT or TERM, but they are killed by HUP for s in TERM HUP KILL; do _verbose "Sending ::1:: to processes inside the tomb:" $s if option_is_set -D; then - ps -fp `fuser -m /media/a.tomb 2>/dev/null`| + ps -fp `lsof -t +D "$1" 2>/dev/null`| while read line; do _verbose $line done fi - fuser -s -m "$1" -k -M -$s - if [[ -z `fuser -m "$1" 2>/dev/null` ]]; then + kill -$s `lsof -t +D "$1"` + if [[ -z `lsof -t +D "$1" 2>/dev/null` ]]; then return 0 fi if ! option_is_set -f; then @@ -2730,7 +2732,12 @@ main() { # Close the tomb # `slam` is used to force closing. umount|close|slam) - [[ "$subcommand" == "slam" ]] && SLAM=1 + [[ "$subcommand" == "slam" ]] && { + SLAM=1 + [[ $LSOF == 0 ]] && { + unset SLAM + _warning "lsof not installed: cannot slam tombs." + _warning "Trying a regular close." }} umount_tomb $PARAM[1] ;;