| 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> |
| |
| Upstream-Status: Pending |
| |
| update this patch to 0.8.2 |
| |
| Signed-off-by: Changqing Li <changqing.li@windriver.com> |
| [OP: Rebase to 0.9.3] |
| [OP: adjusted FREE() -> free(), made set_regex_value() static] |
| Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> |
| --- |
| libmultipath/dict.c | 42 +++++++++++++++++++++++++++++++++++------- |
| 1 file changed, 35 insertions(+), 7 deletions(-) |
| |
| diff --git a/libmultipath/dict.c b/libmultipath/dict.c |
| index aa93fe43..55a22d32 100644 |
| --- a/libmultipath/dict.c |
| +++ b/libmultipath/dict.c |
| @@ -155,6 +155,34 @@ set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr) |
| return 0; |
| } |
| |
| +static 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; |
| +} |
| + |
| +static int |
| +set_regex(vector strvec, void *ptr, const char *file, int line_nr) |
| +{ |
| + 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, const char *file, int line_nr) |
| { |
| @@ -1679,8 +1707,8 @@ 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; \ |
| \ |
| @@ -1700,7 +1728,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; \ |
| \ |
| @@ -1806,16 +1834,16 @@ device_handler(struct config *conf, vector strvec, const char *file, |
| 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) |
| -- |
| 2.38.1 |
| |