blob: 22cb4beeb8a21a29d1013b3c36535bd164635013 [file] [log] [blame]
Brad Bishop00ab2372019-10-14 11:06:18 -04001From 0000000000000000000000000000000000000000 Mon Sep 17
200:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Mon, 6 Nov
32017 21:39:28 -0600 Subject: [PATCH] RH: warn on invalid regex instead of
4failing
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005
6multipath.conf used to allow "*" as a match everything regular expression,
7instead of requiring ".*". Instead of erroring when the old style
8regular expressions are used, it should print a warning and convert
9them.
10
11Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040012
13Upstream-Status: Pending
14
Brad Bishop00ab2372019-10-14 11:06:18 -040015update this patch to 0.8.2
Brad Bishop19323692019-04-05 15:28:33 -040016
17Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler517393d2023-01-13 08:55:19 -060018[OP: Rebase to 0.9.3]
19[OP: adjusted FREE() -> free(), made set_regex_value() static]
20Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080021---
Andrew Geissler517393d2023-01-13 08:55:19 -060022 libmultipath/dict.c | 42 +++++++++++++++++++++++++++++++++++-------
23 1 file changed, 35 insertions(+), 7 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024
25diff --git a/libmultipath/dict.c b/libmultipath/dict.c
Andrew Geissler517393d2023-01-13 08:55:19 -060026index aa93fe43..55a22d32 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027--- a/libmultipath/dict.c
28+++ b/libmultipath/dict.c
Andrew Geissler517393d2023-01-13 08:55:19 -060029@@ -155,6 +155,34 @@ set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr)
30 return 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031 }
32
Andrew Geissler517393d2023-01-13 08:55:19 -060033+static void *
34+set_regex_value(vector strvec)
35+{
36+ char *buff = set_value(strvec);
37+
38+ if (buff && strcmp("*", buff) == 0) {
39+ condlog(0, "Invalid regular expression \"*\" in multipath.conf. Using \".*\"");
40+ free(buff);
41+ return strdup(".*");
42+ }
43+ return buff;
44+}
45+
46+static int
47+set_regex(vector strvec, void *ptr, const char *file, int line_nr)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048+{
Brad Bishop19323692019-04-05 15:28:33 -040049+ char **str_ptr = (char **)ptr;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050+
Brad Bishop19323692019-04-05 15:28:33 -040051+ if (*str_ptr)
Andrew Geissler517393d2023-01-13 08:55:19 -060052+ free(*str_ptr);
Brad Bishop19323692019-04-05 15:28:33 -040053+ *str_ptr = set_regex_value(strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080054+
Brad Bishop19323692019-04-05 15:28:33 -040055+ if (!*str_ptr)
56+ return 1;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057+
Brad Bishop19323692019-04-05 15:28:33 -040058+ return 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080059+}
60+
Andrew Geissler517393d2023-01-13 08:55:19 -060061 static int
62 set_yes_no(vector strvec, void *ptr, const char *file, int line_nr)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080063 {
Andrew Geissler517393d2023-01-13 08:55:19 -060064@@ -1679,8 +1707,8 @@ ble_ ## option ## _handler (struct config *conf, vector strvec, \
Brad Bishop19323692019-04-05 15:28:33 -040065 \
66 if (!conf->option) \
67 return 1; \
68- \
69- buff = set_value(strvec); \
70+ \
71+ buff = set_regex_value(strvec); \
72 if (!buff) \
73 return 1; \
74 \
Andrew Geissler517393d2023-01-13 08:55:19 -060075@@ -1700,7 +1728,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec, \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080076 if (!conf->option) \
77 return 1; \
78 \
79- buff = set_value(strvec); \
80+ buff = set_regex_value(strvec); \
81 if (!buff) \
82 return 1; \
83 \
Andrew Geissler517393d2023-01-13 08:55:19 -060084@@ -1806,16 +1834,16 @@ device_handler(struct config *conf, vector strvec, const char *file,
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080085 return 0;
86 }
87
88-declare_hw_handler(vendor, set_str)
89+declare_hw_handler(vendor, set_regex)
90 declare_hw_snprint(vendor, print_str)
91
92-declare_hw_handler(product, set_str)
93+declare_hw_handler(product, set_regex)
94 declare_hw_snprint(product, print_str)
95
96-declare_hw_handler(revision, set_str)
97+declare_hw_handler(revision, set_regex)
98 declare_hw_snprint(revision, print_str)
99
100-declare_hw_handler(bl_product, set_str)
101+declare_hw_handler(bl_product, set_regex)
102 declare_hw_snprint(bl_product, print_str)
103
104 declare_hw_handler(hwhandler, set_str)
Brad Bishop00ab2372019-10-14 11:06:18 -0400105--
Andrew Geissler517393d2023-01-13 08:55:19 -06001062.38.1
Brad Bishop00ab2372019-10-14 11:06:18 -0400107