|
|
e71b65 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
e71b65 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
e71b65 |
Date: Wed, 8 Feb 2023 19:31:02 -0600
|
|
|
e71b65 |
Subject: [PATCH] libmultipath: limit paths that can get wwid from environment
|
|
|
e71b65 |
|
|
|
e71b65 |
Currently, whenever getting the uid_attribute from udev database fails,
|
|
|
e71b65 |
multipath will try to get it from the environment variables. This
|
|
|
e71b65 |
normally isn't a problem, since either multipath -u is getting called
|
|
|
e71b65 |
from a uevent, and the environment will have the correct value in that
|
|
|
e71b65 |
variable, or that variable won't be set. However, when find_multipaths
|
|
|
e71b65 |
is configured to "smart", this causes problems. For maybe devices,
|
|
|
e71b65 |
multipath needs to get the WWIDs of all the other block devices, to see
|
|
|
e71b65 |
if they match the maybe device wwid. If one of those devices doesn't
|
|
|
e71b65 |
have uid_attribute set in its udev database, multipath will check the
|
|
|
e71b65 |
environment for it, and it will find that variable set to the WWID
|
|
|
e71b65 |
of the maybe device that this uevent is for. This means that all
|
|
|
e71b65 |
devices with no WWID will end up appearing to have the same WWID as
|
|
|
e71b65 |
the maybe device, causing multipath to incorrectly claim it.
|
|
|
e71b65 |
|
|
|
e71b65 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
e71b65 |
---
|
|
|
e71b65 |
libmultipath/discovery.c | 2 +-
|
|
|
e71b65 |
libmultipath/structs.h | 1 +
|
|
|
e71b65 |
multipath/main.c | 2 ++
|
|
|
e71b65 |
3 files changed, 4 insertions(+), 1 deletion(-)
|
|
|
e71b65 |
|
|
|
e71b65 |
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
|
|
e71b65 |
index f593a7bf..a592a54e 100644
|
|
|
e71b65 |
--- a/libmultipath/discovery.c
|
|
|
e71b65 |
+++ b/libmultipath/discovery.c
|
|
|
e71b65 |
@@ -2032,7 +2032,7 @@ get_udev_uid(struct path * pp, char *uid_attribute, struct udev_device *udev)
|
|
|
e71b65 |
const char *value;
|
|
|
e71b65 |
|
|
|
e71b65 |
value = udev_device_get_property_value(udev, uid_attribute);
|
|
|
e71b65 |
- if (!value || strlen(value) == 0)
|
|
|
e71b65 |
+ if ((!value || strlen(value) == 0) && pp->can_use_env_uid)
|
|
|
e71b65 |
value = getenv(uid_attribute);
|
|
|
e71b65 |
if (value && strlen(value)) {
|
|
|
e71b65 |
len = strlcpy(pp->wwid, value, WWID_SIZE);
|
|
|
e71b65 |
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
|
|
|
e71b65 |
index 0867b91d..4b308561 100644
|
|
|
e71b65 |
--- a/libmultipath/structs.h
|
|
|
e71b65 |
+++ b/libmultipath/structs.h
|
|
|
e71b65 |
@@ -360,6 +360,7 @@ struct path {
|
|
|
e71b65 |
int fast_io_fail;
|
|
|
e71b65 |
unsigned int dev_loss;
|
|
|
e71b65 |
int eh_deadline;
|
|
|
e71b65 |
+ bool can_use_env_uid;
|
|
|
e71b65 |
/* configlet pointers */
|
|
|
e71b65 |
vector hwe;
|
|
|
e71b65 |
struct gen_path generic_path;
|
|
|
e71b65 |
diff --git a/multipath/main.c b/multipath/main.c
|
|
|
e71b65 |
index 41d01c7e..e056c51c 100644
|
|
|
e71b65 |
--- a/multipath/main.c
|
|
|
e71b65 |
+++ b/multipath/main.c
|
|
|
e71b65 |
@@ -653,6 +653,8 @@ check_path_valid(const char *name, struct config *conf, bool is_uevent)
|
|
|
e71b65 |
pp = alloc_path();
|
|
|
e71b65 |
if (!pp)
|
|
|
e71b65 |
return RTVL_FAIL;
|
|
|
e71b65 |
+ if (is_uevent)
|
|
|
e71b65 |
+ pp->can_use_env_uid = true;
|
|
|
e71b65 |
|
|
|
e71b65 |
r = is_path_valid(name, conf, pp, is_uevent);
|
|
|
e71b65 |
if (r <= PATH_IS_ERROR || r >= PATH_MAX_VALID_RESULT)
|