device-mapper-multipath/0012-RH-warn-on-invalid-regex-instead-of-failing.patch

122 lines
3.4 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Mon, 6 Nov 2017 21:39:28 -0600
Subject: [PATCH] RH: warn on invalid regex instead of failing
multipath.conf used to allow "*" as a match everything regular expression,
instead of requiring ".*". Instead of erroring when the old style
regular expressions are used, it should print a warning and convert
them.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/dict.c | 27 +++++++++++++++++++++------
libmultipath/parser.c | 13 +++++++++++++
libmultipath/parser.h | 1 +
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
index eaad4f1..95ae09b 100644
--- a/libmultipath/dict.c
+++ b/libmultipath/dict.c
device-mapper-multipath-0.7.7-6.git1a8625a - Update Source to latest upstream commit * Previous patches 0001-0011 are included in this commit - Rename files * Previous patches 0012-0019 are now patches 0021-0028 - Add 0001-libmultipath-fix-tur-checker-timeout.patch - Add 0002-libmultipath-fix-tur-checker-double-locking.patch - Add 0003-libmultipath-fix-tur-memory-misuse.patch - Add 0004-libmultipath-cleanup-tur-locking.patch - Add 0005-libmultipath-fix-tur-checker-timeout-issue.patch * The above 5 patches cleanup locking issues with the tur checker threads - Add 0006-libmultipath-fix-set_int-error-path.patch - Add 0007-libmultipath-fix-length-issues-in-get_vpd_sgio.patch - Add 0008-libmultipath-_install_keyword-cleanup.patch - Add 0009-libmultipath-remove-unused-code.patch - Add 0010-libmultipath-fix-memory-issue-in-path_latency-prio.patch - Add 0011-libmultipath-fix-null-dereference-int-alloc_path_gro.patch - Add 0012-libmutipath-don-t-use-malformed-uevents.patch - Add 0013-multipath-fix-max-array-size-in-print_cmd_valid.patch - Add 0014-multipathd-function-return-value-tweaks.patch - Add 0015-multipathd-minor-fixes.patch - Add 0016-multipathd-remove-useless-check-and-fix-format.patch - Add 0017-multipathd-fix-memory-leak-on-error-in-configure.patch * The above 12 patches fix minor issues found by coverity - Add 0018-libmultipath-Don-t-blank-intialized-paths.patch - Add 0019-libmultipath-Fixup-updating-paths.patch * Fix issues with paths whose wwid was not set or later changes - Add 0020-multipath-tweak-logging-style.patch * multipathd interactive commands now send errors to stderr, instead of syslog * The above 20 patches have been submitted upstream
2018-09-27 22:56:43 +00:00
@@ -58,6 +58,21 @@ set_str(vector strvec, void *ptr)
return 0;
}
+static int
+set_regex(vector strvec, void *ptr)
+{
+ char **str_ptr = (char **)ptr;
+
+ if (*str_ptr)
+ FREE(*str_ptr);
+ *str_ptr = set_regex_value(strvec);
+
+ if (!*str_ptr)
+ return 1;
+
+ return 0;
+}
+
static int
set_yes_no(vector strvec, void *ptr)
{
@@ -1374,7 +1389,7 @@ ble_ ## option ## _handler (struct config *conf, vector strvec) \
if (!conf->option) \
return 1; \
\
- buff = set_value(strvec); \
+ buff = set_regex_value(strvec); \
if (!buff) \
return 1; \
\
@@ -1390,7 +1405,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
if (!conf->option) \
return 1; \
\
- buff = set_value(strvec); \
+ buff = set_regex_value(strvec); \
if (!buff) \
return 1; \
\
@@ -1493,16 +1508,16 @@ device_handler(struct config *conf, vector strvec)
return 0;
}
-declare_hw_handler(vendor, set_str)
+declare_hw_handler(vendor, set_regex)
declare_hw_snprint(vendor, print_str)
-declare_hw_handler(product, set_str)
+declare_hw_handler(product, set_regex)
declare_hw_snprint(product, print_str)
-declare_hw_handler(revision, set_str)
+declare_hw_handler(revision, set_regex)
declare_hw_snprint(revision, print_str)
-declare_hw_handler(bl_product, set_str)
+declare_hw_handler(bl_product, set_regex)
declare_hw_snprint(bl_product, print_str)
declare_hw_handler(hwhandler, set_str)
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
device-mapper-multipath-0.7.7-6.git1a8625a - Update Source to latest upstream commit * Previous patches 0001-0011 are included in this commit - Rename files * Previous patches 0012-0019 are now patches 0021-0028 - Add 0001-libmultipath-fix-tur-checker-timeout.patch - Add 0002-libmultipath-fix-tur-checker-double-locking.patch - Add 0003-libmultipath-fix-tur-memory-misuse.patch - Add 0004-libmultipath-cleanup-tur-locking.patch - Add 0005-libmultipath-fix-tur-checker-timeout-issue.patch * The above 5 patches cleanup locking issues with the tur checker threads - Add 0006-libmultipath-fix-set_int-error-path.patch - Add 0007-libmultipath-fix-length-issues-in-get_vpd_sgio.patch - Add 0008-libmultipath-_install_keyword-cleanup.patch - Add 0009-libmultipath-remove-unused-code.patch - Add 0010-libmultipath-fix-memory-issue-in-path_latency-prio.patch - Add 0011-libmultipath-fix-null-dereference-int-alloc_path_gro.patch - Add 0012-libmutipath-don-t-use-malformed-uevents.patch - Add 0013-multipath-fix-max-array-size-in-print_cmd_valid.patch - Add 0014-multipathd-function-return-value-tweaks.patch - Add 0015-multipathd-minor-fixes.patch - Add 0016-multipathd-remove-useless-check-and-fix-format.patch - Add 0017-multipathd-fix-memory-leak-on-error-in-configure.patch * The above 12 patches fix minor issues found by coverity - Add 0018-libmultipath-Don-t-blank-intialized-paths.patch - Add 0019-libmultipath-Fixup-updating-paths.patch * Fix issues with paths whose wwid was not set or later changes - Add 0020-multipath-tweak-logging-style.patch * multipathd interactive commands now send errors to stderr, instead of syslog * The above 20 patches have been submitted upstream
2018-09-27 22:56:43 +00:00
index 92ef7cf..4289336 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
device-mapper-multipath-0.7.7-6.git1a8625a - Update Source to latest upstream commit * Previous patches 0001-0011 are included in this commit - Rename files * Previous patches 0012-0019 are now patches 0021-0028 - Add 0001-libmultipath-fix-tur-checker-timeout.patch - Add 0002-libmultipath-fix-tur-checker-double-locking.patch - Add 0003-libmultipath-fix-tur-memory-misuse.patch - Add 0004-libmultipath-cleanup-tur-locking.patch - Add 0005-libmultipath-fix-tur-checker-timeout-issue.patch * The above 5 patches cleanup locking issues with the tur checker threads - Add 0006-libmultipath-fix-set_int-error-path.patch - Add 0007-libmultipath-fix-length-issues-in-get_vpd_sgio.patch - Add 0008-libmultipath-_install_keyword-cleanup.patch - Add 0009-libmultipath-remove-unused-code.patch - Add 0010-libmultipath-fix-memory-issue-in-path_latency-prio.patch - Add 0011-libmultipath-fix-null-dereference-int-alloc_path_gro.patch - Add 0012-libmutipath-don-t-use-malformed-uevents.patch - Add 0013-multipath-fix-max-array-size-in-print_cmd_valid.patch - Add 0014-multipathd-function-return-value-tweaks.patch - Add 0015-multipathd-minor-fixes.patch - Add 0016-multipathd-remove-useless-check-and-fix-format.patch - Add 0017-multipathd-fix-memory-leak-on-error-in-configure.patch * The above 12 patches fix minor issues found by coverity - Add 0018-libmultipath-Don-t-blank-intialized-paths.patch - Add 0019-libmultipath-Fixup-updating-paths.patch * Fix issues with paths whose wwid was not set or later changes - Add 0020-multipath-tweak-logging-style.patch * multipathd interactive commands now send errors to stderr, instead of syslog * The above 20 patches have been submitted upstream
2018-09-27 22:56:43 +00:00
@@ -384,6 +384,19 @@ set_value(vector strvec)
return alloc;
}
+void *
+set_regex_value(vector strvec)
+{
+ char *buff = set_value(strvec);
+
+ if (buff && strcmp("*", buff) == 0) {
+ condlog(0, "Invalid regular expression \"*\" in multipath.conf. Using \".*\"");
+ FREE(buff);
+ return strdup(".*");
+ }
+ return buff;
+}
+
/* non-recursive configuration stream handler */
static int kw_level = 0;
diff --git a/libmultipath/parser.h b/libmultipath/parser.h
index 62906e9..b791705 100644
--- a/libmultipath/parser.h
+++ b/libmultipath/parser.h
@@ -77,6 +77,7 @@ extern void dump_keywords(vector keydump, int level);
extern void free_keywords(vector keywords);
extern vector alloc_strvec(char *string);
extern void *set_value(vector strvec);
+extern void *set_regex_value(vector strvec);
extern int process_file(struct config *conf, char *conf_file);
extern struct keyword * find_keyword(vector keywords, vector v, char * name);
int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw,
--
2.17.2