Merge pull request #243 from Narrat/bug/slam

Use of lsof to fix slam for specific mountpoint
This commit is contained in:
Jaromil 2017-02-06 11:52:08 +01:00 committed by GitHub
commit 5b7f875f3d
4 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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

Binary file not shown.

17
tomb
View File

@ -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]
;;