Use of lsof to fix slam for specific mountpoint

Apparantly fuser didn't report back, if the tomb was mounted in a subdir of /run (whereas /run itself is often a tmpfs mount).
With no list of process ids those couldn't be killed, so slamming the tomb failed.
lsof is capable to report back the sought information.

Fixes #220

Additionally fixing the debug output, where a hardcoded mountpoint was used
This commit is contained in:
Narrat 2017-02-03 17:39:09 +01:00
parent 1f852908ae
commit 537bb6aaeb
2 changed files with 5 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Tomb needs a few programs to be installed on a system in order to work:
* gnupg
* cryptsetup
* pinentry-curses (and/or -gtk-2, -x11, -qt)
* lsof
Most systems provide these tools in their package collection, for
instance on Debian/Ubuntu one can use `apt-get install` on Fedora and

8
tomb
View File

@ -2506,20 +2506,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