Blame SOURCES/0015-RH-don-t-start-without-a-config-file.patch

68b27c
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
68b27c
From: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
Date: Wed, 15 Oct 2014 10:39:30 -0500
68b27c
Subject: [PATCH] RH: don't start without a config file
68b27c
68b27c
If /etc/multipath.conf doesn't exist, don't start multipathd and blacklist
68b27c
all devices when running multipath.  A completely blank configuration file
68b27c
is almost never what users want.  Also, people may have the multipath
68b27c
packages installed but don't want to use them.  This patch provides a
68b27c
simple way to disable multipath.  Simply removing or renaming
68b27c
/etc/multipath.conf will keep multipath from doing anything.
68b27c
68b27c
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
68b27c
---
68b27c
 libmultipath/config.c         | 13 +++++++++++++
68b27c
 libmultipath/config.h         |  1 +
68b27c
 multipath/multipath.rules     |  1 +
68b27c
 multipathd/multipathd.8       |  2 ++
68b27c
 multipathd/multipathd.service |  1 +
ebef98
 multipathd/multipathd.socket  |  1 +
ebef98
 6 files changed, 19 insertions(+)
68b27c
68b27c
diff --git a/libmultipath/config.c b/libmultipath/config.c
68b27c
index 30046a17..5f35c3d3 100644
68b27c
--- a/libmultipath/config.c
68b27c
+++ b/libmultipath/config.c
68b27c
@@ -895,6 +895,19 @@ int _init_config (const char *file, struct config *conf)
68b27c
 			goto out;
68b27c
 		}
68b27c
 		factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
68b27c
+	} else {
68b27c
+		condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
68b27c
+		if (conf->blist_devnode == NULL) {
68b27c
+			conf->blist_devnode = vector_alloc();
68b27c
+			if (!conf->blist_devnode) {
68b27c
+				condlog(0, "cannot allocate blacklist\n");
68b27c
+				goto out;
68b27c
+			}
68b27c
+		}
68b27c
+		if (store_ble(conf->blist_devnode, ".*", ORIGIN_NO_CONFIG)) {
68b27c
+			condlog(0, "cannot store default no-config blacklist\n");
68b27c
+			goto out;
68b27c
+		}
68b27c
 	}
68b27c
 
68b27c
 	conf->processed_main_config = 1;
68b27c
diff --git a/libmultipath/config.h b/libmultipath/config.h
68b27c
index 933fe0d1..5f01c1fc 100644
68b27c
--- a/libmultipath/config.h
68b27c
+++ b/libmultipath/config.h
68b27c
@@ -9,6 +9,7 @@
68b27c
 
68b27c
 #define ORIGIN_DEFAULT 0
68b27c
 #define ORIGIN_CONFIG  1
68b27c
+#define ORIGIN_NO_CONFIG 2
68b27c
 
68b27c
 enum devtypes {
68b27c
 	DEV_NONE,
68b27c
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
68b27c
index 9df11a95..0486bf70 100644
68b27c
--- a/multipath/multipath.rules
68b27c
+++ b/multipath/multipath.rules
68b27c
@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath"
68b27c
 ENV{nompath}=="?*", GOTO="end_mpath"
68b27c
 IMPORT{cmdline}="multipath"
68b27c
 ENV{multipath}=="off", GOTO="end_mpath"
68b27c
+TEST!="/etc/multipath.conf", GOTO="end_mpath"
68b27c
 
68b27c
 ENV{DEVTYPE}!="partition", GOTO="test_dev"
68b27c
 IMPORT{parent}="DM_MULTIPATH_DEVICE_PATH"
68b27c
diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8
68b27c
index 048a838d..8bd47a80 100644
68b27c
--- a/multipathd/multipathd.8
68b27c
+++ b/multipathd/multipathd.8
68b27c
@@ -39,6 +39,8 @@ map regains its maximum performance and redundancy.
68b27c
 This daemon executes the external \fBmultipath\fR tool when events occur.
68b27c
 In turn, the multipath tool signals the multipathd daemon when it is done with
68b27c
 devmap reconfiguration, so that it can refresh its failed path list.
68b27c
+
68b27c
+In this Linux distribution, multipathd does not run unless a /etc/multipath.conf file exists.
68b27c
 .
68b27c
 .
68b27c
 .\" ----------------------------------------------------------------------------
68b27c
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
ebef98
index 0b2ac814..6d57c7e8 100644
68b27c
--- a/multipathd/multipathd.service
68b27c
+++ b/multipathd/multipathd.service
68b27c
@@ -4,6 +4,7 @@ Wants=systemd-udev-trigger.service systemd-udev-settle.service
68b27c
 Before=iscsi.service iscsid.service lvm2-activation-early.service
68b27c
 Before=local-fs-pre.target blk-availability.service shutdown.target
68b27c
 After=multipathd.socket systemd-udev-trigger.service systemd-udev-settle.service
68b27c
+ConditionPathExists=/etc/multipath.conf
68b27c
 DefaultDependencies=no
68b27c
 Conflicts=shutdown.target
68b27c
 ConditionKernelCommandLine=!nompath
ebef98
diff --git a/multipathd/multipathd.socket b/multipathd/multipathd.socket
ebef98
index c777e5e3..3c20a2ff 100644
ebef98
--- a/multipathd/multipathd.socket
ebef98
+++ b/multipathd/multipathd.socket
ebef98
@@ -1,6 +1,7 @@
ebef98
 [Unit]
ebef98
 Description=multipathd control socket
ebef98
 DefaultDependencies=no
ebef98
+ConditionPathExists=/etc/multipath.conf
ebef98
 ConditionKernelCommandLine=!nompath
ebef98
 ConditionKernelCommandLine=!multipath=off
ebef98
 ConditionVirtualization=!container