blob: 95624ad7a91055b549d3c741d3c32aeab5d3deb4 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001From 56d65ecb1c6d814929f6ff3159ade09dc203cc83 Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Changqing Li <changqing.li@windriver.com>
3Date: Mon, 26 Nov 2018 10:31:30 +0800
4Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep 17
5 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Mon, 6 Nov
6 2017 21:39:28 -0600 Subject: [PATCH] RH: warn on invalid regex instead of
7 failing
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08008
9multipath.conf used to allow "*" as a match everything regular expression,
10instead of requiring ".*". Instead of erroring when the old style
11regular expressions are used, it should print a warning and convert
12them.
13
14Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040015
16Upstream-Status: Pending
17
18update this patch to new version
19
20Signed-off-by: Changqing Li <changqing.li@windriver.com>
Brad Bishopc342db32019-05-15 21:57:59 -040021
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022---
Brad Bishop19323692019-04-05 15:28:33 -040023 libmultipath/dict.c | 29 ++++++++++++++++++++++-------
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 libmultipath/parser.c | 13 +++++++++++++
Brad Bishopc342db32019-05-15 21:57:59 -040025 libmultipath/parser.h | 1 +
26 3 files changed, 36 insertions(+), 7 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027
28diff --git a/libmultipath/dict.c b/libmultipath/dict.c
Brad Bishopc342db32019-05-15 21:57:59 -040029index eaad4f1..fb30577 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030--- a/libmultipath/dict.c
31+++ b/libmultipath/dict.c
Brad Bishop19323692019-04-05 15:28:33 -040032@@ -59,6 +59,21 @@ set_str(vector strvec, void *ptr)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033 }
34
35 static int
36+set_regex(vector strvec, void *ptr)
37+{
Brad Bishop19323692019-04-05 15:28:33 -040038+ char **str_ptr = (char **)ptr;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080039+
Brad Bishop19323692019-04-05 15:28:33 -040040+ if (*str_ptr)
41+ FREE(*str_ptr);
42+ *str_ptr = set_regex_value(strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043+
Brad Bishop19323692019-04-05 15:28:33 -040044+ if (!*str_ptr)
45+ return 1;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046+
Brad Bishop19323692019-04-05 15:28:33 -040047+ return 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048+}
49+
50+static int
51 set_yes_no(vector strvec, void *ptr)
52 {
53 char * buff;
Brad Bishopc342db32019-05-15 21:57:59 -040054@@ -1373,8 +1388,8 @@ ble_ ## option ## _handler (struct config *conf, vector strvec) \
Brad Bishop19323692019-04-05 15:28:33 -040055 \
56 if (!conf->option) \
57 return 1; \
58- \
59- buff = set_value(strvec); \
60+ \
61+ buff = set_regex_value(strvec); \
62 if (!buff) \
63 return 1; \
64 \
Brad Bishopc342db32019-05-15 21:57:59 -040065@@ -1390,7 +1405,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080066 if (!conf->option) \
67 return 1; \
68 \
69- buff = set_value(strvec); \
70+ buff = set_regex_value(strvec); \
71 if (!buff) \
72 return 1; \
73 \
Brad Bishopc342db32019-05-15 21:57:59 -040074@@ -1493,16 +1508,16 @@ device_handler(struct config *conf, vector strvec)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080075 return 0;
76 }
77
78-declare_hw_handler(vendor, set_str)
79+declare_hw_handler(vendor, set_regex)
80 declare_hw_snprint(vendor, print_str)
81
82-declare_hw_handler(product, set_str)
83+declare_hw_handler(product, set_regex)
84 declare_hw_snprint(product, print_str)
85
86-declare_hw_handler(revision, set_str)
87+declare_hw_handler(revision, set_regex)
88 declare_hw_snprint(revision, print_str)
89
90-declare_hw_handler(bl_product, set_str)
91+declare_hw_handler(bl_product, set_regex)
92 declare_hw_snprint(bl_product, print_str)
93
94 declare_hw_handler(hwhandler, set_str)
95diff --git a/libmultipath/parser.c b/libmultipath/parser.c
Brad Bishop19323692019-04-05 15:28:33 -040096index 92ef7cf..0e2cf49 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080097--- a/libmultipath/parser.c
98+++ b/libmultipath/parser.c
Brad Bishop19323692019-04-05 15:28:33 -040099@@ -384,6 +384,19 @@ set_value(vector strvec)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800100 return alloc;
101 }
102
103+void *
104+set_regex_value(vector strvec)
105+{
Brad Bishop19323692019-04-05 15:28:33 -0400106+ char *buff = set_value(strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800107+
Brad Bishop19323692019-04-05 15:28:33 -0400108+ if (buff && strcmp("*", buff) == 0) {
109+ condlog(0, "Invalid regular expression \"*\" in multipath.conf. Using \".*\"");
110+ FREE(buff);
111+ return strdup(".*");
112+ }
113+ return buff;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800114+}
115+
116 /* non-recursive configuration stream handler */
117 static int kw_level = 0;
118
119diff --git a/libmultipath/parser.h b/libmultipath/parser.h
Brad Bishopc342db32019-05-15 21:57:59 -0400120index 62906e9..b791705 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800121--- a/libmultipath/parser.h
122+++ b/libmultipath/parser.h
Brad Bishopc342db32019-05-15 21:57:59 -0400123@@ -77,6 +77,7 @@ extern void dump_keywords(vector keydump, int level);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800124 extern void free_keywords(vector keywords);
125 extern vector alloc_strvec(char *string);
Brad Bishopc342db32019-05-15 21:57:59 -0400126 extern void *set_value(vector strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800127+extern void *set_regex_value(vector strvec);
128 extern int process_file(struct config *conf, char *conf_file);
129 extern struct keyword * find_keyword(vector keywords, vector v, char * name);
130 int snprint_keyword(char *buff, int len, char *fmt, struct keyword *kw,