|
|
68b27c |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
68b27c |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
68b27c |
Date: Fri, 9 Jul 2021 14:30:10 -0500
|
|
|
68b27c |
Subject: [PATCH] RH: mpathconf: correctly handle spaces after option names
|
|
|
68b27c |
|
|
|
68b27c |
mpathconf was either accepting any number of spaces, including zero,
|
|
|
68b27c |
after option names, or it was only accepting one space. It should
|
|
|
68b27c |
accept one or more spaces. Also, fix enable_foreign handling. It was
|
|
|
68b27c |
still working like it did in RHEL8, where the default was to enable
|
|
|
68b27c |
all foreign devices.
|
|
|
68b27c |
|
|
|
68b27c |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
68b27c |
---
|
|
|
68b27c |
multipath/mpathconf | 62 +++++++++++++++++++++++++--------------------
|
|
|
68b27c |
1 file changed, 34 insertions(+), 28 deletions(-)
|
|
|
68b27c |
|
|
|
68b27c |
diff --git a/multipath/mpathconf b/multipath/mpathconf
|
|
|
68b27c |
index 2f4f3eaf..039b3e47 100644
|
|
|
68b27c |
--- a/multipath/mpathconf
|
|
|
68b27c |
+++ b/multipath/mpathconf
|
|
|
68b27c |
@@ -240,7 +240,7 @@ function validate_args
|
|
|
68b27c |
echo "--enable_foreign must be either 'y' or 'n'"
|
|
|
68b27c |
exit 1
|
|
|
68b27c |
fi
|
|
|
68b27c |
- if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" ]; then
|
|
|
68b27c |
+ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" ]; then
|
|
|
68b27c |
SHOW_STATUS=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
|
|
|
68b27c |
@@ -315,46 +315,50 @@ if [ "$MULTIPATHD" = "y" ]; then
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
|
68b27c |
- if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
|
68b27c |
+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode[[:space:]][[:space:]]*\"\.\?\*\"" ; then
|
|
|
68b27c |
HAVE_DISABLE=1
|
|
|
68b27c |
- elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"" ; then
|
|
|
68b27c |
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode[[:space:]][[:space:]]*\"\.\?\*\"" ; then
|
|
|
68b27c |
HAVE_DISABLE=0
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$HAVE_BLACKLIST" = "1" ]; then
|
|
|
68b27c |
- if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
|
68b27c |
+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid[[:space:]][[:space:]]*\"\.\?\*\"" ; then
|
|
|
68b27c |
HAVE_WWID_DISABLE=1
|
|
|
68b27c |
- elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"" ; then
|
|
|
68b27c |
+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid[[:space:]][[:space:]]*\"\.\?\*\"" ; then
|
|
|
68b27c |
HAVE_WWID_DISABLE=0
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$HAVE_DEFAULTS" = "1" ]; then
|
|
|
68b27c |
- HAVE_FIND=`sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | sed -n 's/^[[:blank:]]*find_multipaths[[:blank:]]*\([^[:blank:]]*\).*$/\1/p' | sed -n 1p`
|
|
|
68b27c |
+ HAVE_FIND=`sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | sed -n 's/^[[:blank:]]*find_multipaths[[:blank:]][[:blank:]]*\([^[:blank:]]*\).*$/\1/p' | sed -n 1p`
|
|
|
68b27c |
if [ "$HAVE_FIND" = "1" ]; then
|
|
|
68b27c |
HAVE_FIND="yes"
|
|
|
68b27c |
elif [ "$HAVE_FIND" = "0" ]; then
|
|
|
68b27c |
HAVE_FIND="no"
|
|
|
68b27c |
fi
|
|
|
68b27c |
- if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
|
|
|
68b27c |
+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(yes\|1\)" ; then
|
|
|
68b27c |
HAVE_FRIENDLY=1
|
|
|
68b27c |
- elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
|
|
|
68b27c |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(no\|0\)" ; then
|
|
|
68b27c |
HAVE_FRIENDLY=0
|
|
|
68b27c |
fi
|
|
|
68b27c |
if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*enable_foreign" ; then
|
|
|
68b27c |
HAVE_FOREIGN=0
|
|
|
68b27c |
- elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]]*\"\^\$\"" ; then
|
|
|
68b27c |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"\.\*\"" ; then
|
|
|
68b27c |
HAVE_FOREIGN=1
|
|
|
68b27c |
- elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then
|
|
|
68b27c |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"\^\$\"" ; then
|
|
|
68b27c |
+ HAVE_FOREIGN=2
|
|
|
68b27c |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign[[:space:]][[:space:]]*\"NONE\"" ; then
|
|
|
68b27c |
HAVE_FOREIGN=2
|
|
|
68b27c |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then
|
|
|
68b27c |
+ HAVE_FOREIGN=3
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$HAVE_EXCEPTIONS" = "1" ]; then
|
|
|
68b27c |
- if sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then
|
|
|
68b27c |
+ if sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then
|
|
|
68b27c |
HAVE_PROPERTY=1
|
|
|
68b27c |
- elif sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then
|
|
|
68b27c |
+ elif sed -n '/^blacklist_exceptions[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"" ; then
|
|
|
68b27c |
HAVE_PROPERTY=0
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
@@ -381,8 +385,10 @@ if [ -n "$SHOW_STATUS" ]; then
|
|
|
68b27c |
echo "default property blacklist is enabled"
|
|
|
68b27c |
fi
|
|
|
68b27c |
if [ -z "$HAVE_FOREIGN" -o "$HAVE_FOREIGN" = 0 ]; then
|
|
|
68b27c |
- echo "enable_foreign is not set (all foreign multipath devices will be shown)"
|
|
|
68b27c |
+ echo "enable_foreign is not set (no foreign multipath devices will be shown)"
|
|
|
68b27c |
elif [ "$HAVE_FOREIGN" = 1 ]; then
|
|
|
68b27c |
+ echo "enable_foreign is set (all foreign multipath devices will be shown)"
|
|
|
68b27c |
+ elif [ "$HAVE_FOREIGN" = 2 ]; then
|
|
|
68b27c |
echo "enable_foreign is set (no foreign multipath devices will be shown)"
|
|
|
68b27c |
else
|
|
|
68b27c |
echo "enable_foreign is set (foreign multipath devices may not be shown)"
|
|
|
68b27c |
@@ -427,14 +433,14 @@ fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$ENABLE" = 2 ]; then
|
|
|
68b27c |
if [ "$HAVE_DISABLE" = 1 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode[[:space:]][[:space:]]*\"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
68b27c |
fi
|
|
|
68b27c |
if [ -z "$HAVE_WWID_DISABLE" ]; then
|
|
|
68b27c |
sed -i '/^blacklist[[:space:]]*{/ a\
|
|
|
68b27c |
wwid ".*"
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
elif [ "$HAVE_WWID_DISABLE" = 0 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/ wwid ".*"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid[[:space:]][[:space:]]*\"\.\?\*\"/ wwid ".*"/' $TMPFILE
|
|
|
68b27c |
fi
|
|
|
68b27c |
if [ "$HAVE_EXCEPTIONS" = 1 ]; then
|
|
|
68b27c |
sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ {/^[[:space:]]*wwid/ d}' $TMPFILE
|
|
|
68b27c |
@@ -448,7 +454,7 @@ _EOF_
|
|
|
68b27c |
add_blacklist_exceptions
|
|
|
68b27c |
elif [ "$ENABLE" = 1 ]; then
|
|
|
68b27c |
if [ "$HAVE_DISABLE" = 1 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode[[:space:]][[:space:]]*\"\.\?\*\"/# devnode ".*"/' $TMPFILE
|
|
|
68b27c |
fi
|
|
|
68b27c |
elif [ "$ENABLE" = 0 ]; then
|
|
|
68b27c |
if [ -z "$HAVE_DISABLE" ]; then
|
|
|
68b27c |
@@ -456,7 +462,7 @@ elif [ "$ENABLE" = 0 ]; then
|
|
|
68b27c |
devnode ".*"
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
elif [ "$HAVE_DISABLE" = 0 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode[[:space:]][[:space:]]*\"\.\?\*\"/ devnode ".*"/' $TMPFILE
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
@@ -467,14 +473,14 @@ if [ -n "$FIND" ]; then
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
elif [ "$FIND" != "$HAVE_FIND" ]; then
|
|
|
68b27c |
- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:blank:]]*find_multipaths[[:blank:]]*[^[:blank:]]*/ find_multipaths '"$FIND"'/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:blank:]]*find_multipaths[[:blank:]][[:blank:]]*[^[:blank:]]*/ find_multipaths '"$FIND"'/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$FRIENDLY" = "n" ]; then
|
|
|
68b27c |
if [ "$HAVE_FRIENDLY" = 1 ]; then
|
|
|
68b27c |
- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
elif [ "$FRIENDLY" = "y" ]; then
|
|
|
68b27c |
@@ -484,14 +490,14 @@ elif [ "$FRIENDLY" = "y" ]; then
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
elif [ "$HAVE_FRIENDLY" = 0 ]; then
|
|
|
68b27c |
- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]][[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
if [ "$PROPERTY" = "n" ]; then
|
|
|
68b27c |
if [ "$HAVE_PROPERTY" = 1 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/# property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/# property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
elif [ "$PROPERTY" = "y" ]; then
|
|
|
68b27c |
@@ -501,24 +507,24 @@ elif [ "$PROPERTY" = "y" ]; then
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
elif [ "$HAVE_PROPERTY" = 0 ]; then
|
|
|
68b27c |
- sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*property[[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/ property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE
|
|
|
68b27c |
+ sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*property[[:space:]][[:space:]]*\"(SCSI_IDENT_|ID_WWN)\"/ property \"(SCSI_IDENT_|ID_WWN)\"/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|
|
|
68b27c |
|
|
|
68b27c |
-if [ "$FOREIGN" = "y" ]; then
|
|
|
68b27c |
- if [ "$HAVE_FOREIGN" = 1 -o "$HAVE_FOREIGN" = 2 ]; then
|
|
|
68b27c |
+if [ "$FOREIGN" = "n" ]; then
|
|
|
68b27c |
+ if [ "$HAVE_FOREIGN" = 1 -o "$HAVE_FOREIGN" = 3 ]; then
|
|
|
68b27c |
sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*enable_foreign/# enable_foreign/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
-elif [ "$FOREIGN" = "n" ]; then
|
|
|
68b27c |
+elif [ "$FOREIGN" = "y" ]; then
|
|
|
68b27c |
if [ -z "$HAVE_FOREIGN" ]; then
|
|
|
68b27c |
sed -i '/^defaults[[:space:]]*{/ a\
|
|
|
68b27c |
- enable_foreign "^$"
|
|
|
68b27c |
+ enable_foreign ".*"
|
|
|
68b27c |
' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
- elif [ "$HAVE_FOREIGN" = 0 -o "$HAVE_FOREIGN" = 2 ]; then
|
|
|
68b27c |
- sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*#\?[[:space:]]*enable_foreign.*$/ enable_foreign "^$"/' $TMPFILE
|
|
|
68b27c |
+ elif [ "$HAVE_FOREIGN" = 0 -o "$HAVE_FOREIGN" = 2 -o "$HAVE_FOREIGN" = 3 ]; then
|
|
|
68b27c |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*#\?[[:space:]]*enable_foreign.*$/ enable_foreign ".*"/' $TMPFILE
|
|
|
68b27c |
CHANGED_CONFIG=1
|
|
|
68b27c |
fi
|
|
|
68b27c |
fi
|