blob: 57d04d02bbc2ab2b71153b65851becc27a225094 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From d16de70b76919269561b4e404825f78286ea9a40 Mon Sep 17 00:00:00 2001
2From: 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 Bishop1a4b7ee2018-12-16 17:11:34 -080021---
Brad Bishop19323692019-04-05 15:28:33 -040022 libmultipath/dict.c | 29 ++++++++++++++++++++++-------
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080023 libmultipath/parser.c | 13 +++++++++++++
Brad Bishop19323692019-04-05 15:28:33 -040024 libmultipath/parser.h | 2 +-
25 3 files changed, 36 insertions(+), 8 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026
27diff --git a/libmultipath/dict.c b/libmultipath/dict.c
Brad Bishop19323692019-04-05 15:28:33 -040028index a81c051..0689763 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080029--- a/libmultipath/dict.c
30+++ b/libmultipath/dict.c
Brad Bishop19323692019-04-05 15:28:33 -040031@@ -59,6 +59,21 @@ set_str(vector strvec, void *ptr)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032 }
33
34 static int
35+set_regex(vector strvec, void *ptr)
36+{
Brad Bishop19323692019-04-05 15:28:33 -040037+ char **str_ptr = (char **)ptr;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038+
Brad Bishop19323692019-04-05 15:28:33 -040039+ if (*str_ptr)
40+ FREE(*str_ptr);
41+ *str_ptr = set_regex_value(strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042+
Brad Bishop19323692019-04-05 15:28:33 -040043+ if (!*str_ptr)
44+ return 1;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080045+
Brad Bishop19323692019-04-05 15:28:33 -040046+ return 0;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047+}
48+
49+static int
50 set_yes_no(vector strvec, void *ptr)
51 {
52 char * buff;
Brad Bishop19323692019-04-05 15:28:33 -040053@@ -1346,8 +1361,8 @@ ble_ ## option ## _handler (struct config *conf, vector strvec) \
54 \
55 if (!conf->option) \
56 return 1; \
57- \
58- buff = set_value(strvec); \
59+ \
60+ buff = set_regex_value(strvec); \
61 if (!buff) \
62 return 1; \
63 \
64@@ -1363,7 +1378,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080065 if (!conf->option) \
66 return 1; \
67 \
68- buff = set_value(strvec); \
69+ buff = set_regex_value(strvec); \
70 if (!buff) \
71 return 1; \
72 \
Brad Bishop19323692019-04-05 15:28:33 -040073@@ -1466,16 +1481,16 @@ device_handler(struct config *conf, vector strvec)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080074 return 0;
75 }
76
77-declare_hw_handler(vendor, set_str)
78+declare_hw_handler(vendor, set_regex)
79 declare_hw_snprint(vendor, print_str)
80
81-declare_hw_handler(product, set_str)
82+declare_hw_handler(product, set_regex)
83 declare_hw_snprint(product, print_str)
84
85-declare_hw_handler(revision, set_str)
86+declare_hw_handler(revision, set_regex)
87 declare_hw_snprint(revision, print_str)
88
89-declare_hw_handler(bl_product, set_str)
90+declare_hw_handler(bl_product, set_regex)
91 declare_hw_snprint(bl_product, print_str)
92
93 declare_hw_handler(hwhandler, set_str)
94diff --git a/libmultipath/parser.c b/libmultipath/parser.c
Brad Bishop19323692019-04-05 15:28:33 -040095index 92ef7cf..0e2cf49 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080096--- a/libmultipath/parser.c
97+++ b/libmultipath/parser.c
Brad Bishop19323692019-04-05 15:28:33 -040098@@ -384,6 +384,19 @@ set_value(vector strvec)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080099 return alloc;
100 }
101
102+void *
103+set_regex_value(vector strvec)
104+{
Brad Bishop19323692019-04-05 15:28:33 -0400105+ char *buff = set_value(strvec);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800106+
Brad Bishop19323692019-04-05 15:28:33 -0400107+ if (buff && strcmp("*", buff) == 0) {
108+ condlog(0, "Invalid regular expression \"*\" in multipath.conf. Using \".*\"");
109+ FREE(buff);
110+ return strdup(".*");
111+ }
112+ return buff;
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800113+}
114+
115 /* non-recursive configuration stream handler */
116 static int kw_level = 0;
117
118diff --git a/libmultipath/parser.h b/libmultipath/parser.h
Brad Bishop19323692019-04-05 15:28:33 -0400119index 62906e9..b6899fc 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800120--- a/libmultipath/parser.h
121+++ b/libmultipath/parser.h
Brad Bishop19323692019-04-05 15:28:33 -0400122@@ -76,7 +76,7 @@ extern int _install_keyword(vector keywords, char *string,
123 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 Bishop19323692019-04-05 15:28:33 -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,
131--
1322.7.4
133