summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2017-02-06 10:52:08 (GMT)
committer GitHub <noreply@github.com>2017-02-06 10:52:08 (GMT)
commit5b7f875f3d92ae13b7cc2570f4cc08d7c30f2a87 (patch)
tree3e26e3fbf1a5553088e8d67f600ef5fa2eef5ebc
parent1f852908ae669cabcce0c3206baea33bb10c1ee3 (diff)
parentb2ee2114cff508dfab8277559840aaa7865cc058 (diff)
Merge pull request #243 from Narrat/bug/slam
Use of lsof to fix slam for specific mountpoint
-rw-r--r--INSTALL.md1
-rw-r--r--doc/tomb.16
-rw-r--r--doc/tomb_manpage.pdfbin21750 -> 30887 bytes
-rwxr-xr-xtomb17
4 files changed, 16 insertions, 8 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 996ada3..e25e7a0 100644
--- 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
index 775bc19..d032bd8 100644
--- 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
index 55aa72d..d2bcad2 100644
--- a/doc/tomb_manpage.pdf
+++ b/doc/tomb_manpage.pdf
Binary files differ
diff --git a/tomb b/tomb
index 1a1a632..e198fc6 100755
--- 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]
;;