Source: multipath-tools
Version: 0.5.0-7
Severity: normal
Tags: patch
Hi,
The init script of multipath-tools throws this error message on wheezy
(same for jessie and unstable) when stopping the daemon:
/etc/init.d/multipath-tools: 75: [: /sys/block/dm-1: unexpected operator
[ ok ] Stopping multipath daemon: multipathd.
The problem start with
root_dev=$(awk '{ if ($1 !~ /^[ \t]*#/ && $1 ~ /\// && $2 == "/") { print
$1; }}' /etc/mtab)
This command evalutes to an empty string on my system. In consequence,
the next command
dm_num=$(dmsetup info -c --noheadings -o minor $root_dev 2>/dev/null)
queries dmsetup for all devices instead of the root device. Then
root_dm_device contains new lines and let the directory test stumble.
Thus only query dmsetup if a root device is found. Do nothing when no
DM number can determined (instead of using the echo command as no-op).
The patch to fix the init script is attached.
--
Benjamin Drung
System Developer
Debian & Ubuntu Developer
ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin
Email: [email protected]
URL: http://www.profitbricks.com
Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
>From aef8d370759de29da2bdbcdf664c53757aa4d199 Mon Sep 17 00:00:00 2001
From: Benjamin Drung <[email protected]>
Date: Wed, 12 Aug 2015 16:17:08 +0200
Subject: [PATCH] init: Fix stop failure when no root device is found
The init script of multipath-tools throws this error message on wheezy
(same for jessie and unstable) when stopping the daemon:
/etc/init.d/multipath-tools: 75: [: /sys/block/dm-1: unexpected operator
[ ok ] Stopping multipath daemon: multipathd.
The problem start with
root_dev=$(awk '{ if ($1 !~ /^[ \t]*#/ && $1 ~ /\// && $2 == "/") { print $1; }}' /etc/mtab)
This command evalutes to an empty string on my system. In consequence,
the next command
dm_num=$(dmsetup info -c --noheadings -o minor $root_dev 2>/dev/null)
queries dmsetup for all devices instead of the root device. Then
root_dm_device contains new lines and let the directory test stumble.
Thus only query dmsetup if a root device is found. Do nothing when no
DM number can determined (instead of using the echo command as no-op).
---
debian/multipath-tools.init | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/debian/multipath-tools.init b/debian/multipath-tools.init
index 79449bf..77bd5e8 100755
--- a/debian/multipath-tools.init
+++ b/debian/multipath-tools.init
@@ -63,16 +63,20 @@ case "$1" in
;;
stop)
DONT_STOP_MPATHD=0
- root_dev=$(awk '{ if ($1 !~ /^[ \t]*#/ && $1 ~ /\// && $2 == "/") { print $1; }}' /etc/mtab)
- dm_num=$(dmsetup info -c --noheadings -o minor $root_dev 2>/dev/null)
- if [ $? -ne 0 ]; then
+ root_dev=$(awk '{ if ($1 !~ /^[ \t]*#/ && $1 ~ /\// && $2 == "/") { print $1; }}' /etc/mtab)
+ if [ -n "$root_dev" ]; then
+ dm_num=$(dmsetup info -c --noheadings -o minor $root_dev 2>/dev/null)
+ else
+ dm_num=
+ fi
+ if [ $? -ne 0 -o -z "$dm_num" ]; then
# Looks like we couldn't find a device mapper root device
# But we shouldn't bail out here, otherwise the stop target and the
# upgrade processes will break. See DBUG #674733
- echo;
+ :
else
root_dm_device="dm-$dm_num"
- [ -d $syspath/$root_dm_device ] && teardown_slaves $syspath/$root_dm_device
+ [ -d "$syspath/$root_dm_device" ] && teardown_slaves $syspath/$root_dm_device
fi
if [ x$DONT_STOP_MPATHD = x0 ]; then
--
2.1.4