Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 |
| 2 | 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Mon, 6 Nov |
| 3 | 2017 21:39:28 -0600 Subject: [PATCH] RH: warn on invalid regex instead of |
| 4 | failing |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | |
| 6 | multipath.conf used to allow "*" as a match everything regular expression, |
| 7 | instead of requiring ".*". Instead of erroring when the old style |
| 8 | regular expressions are used, it should print a warning and convert |
| 9 | them. |
| 10 | |
| 11 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 12 | |
| 13 | Upstream-Status: Pending |
| 14 | |
Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 15 | update this patch to 0.8.2 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 16 | |
| 17 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 18 | [OP: Rebase to 0.9.3] |
| 19 | [OP: adjusted FREE() -> free(), made set_regex_value() static] |
| 20 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 21 | --- |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 22 | libmultipath/dict.c | 42 +++++++++++++++++++++++++++++++++++------- |
| 23 | 1 file changed, 35 insertions(+), 7 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 24 | |
| 25 | diff --git a/libmultipath/dict.c b/libmultipath/dict.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 26 | index aa93fe43..55a22d32 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 27 | --- a/libmultipath/dict.c |
| 28 | +++ b/libmultipath/dict.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 29 | @@ -155,6 +155,34 @@ set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr) |
| 30 | return 0; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 31 | } |
| 32 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 33 | +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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | +{ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 49 | + char **str_ptr = (char **)ptr; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 50 | + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 51 | + if (*str_ptr) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 52 | + free(*str_ptr); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 53 | + *str_ptr = set_regex_value(strvec); |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 54 | + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 55 | + if (!*str_ptr) |
| 56 | + return 1; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | + |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | + return 0; |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 59 | +} |
| 60 | + |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 61 | static int |
| 62 | set_yes_no(vector strvec, void *ptr, const char *file, int line_nr) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 63 | { |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 64 | @@ -1679,8 +1707,8 @@ ble_ ## option ## _handler (struct config *conf, vector strvec, \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 65 | \ |
| 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 Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 75 | @@ -1700,7 +1728,7 @@ ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec, \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 76 | 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 Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 84 | @@ -1806,16 +1834,16 @@ device_handler(struct config *conf, vector strvec, const char *file, |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 85 | 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 Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 105 | -- |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 106 | 2.38.1 |
Brad Bishop | 00ab237 | 2019-10-14 11:06:18 -0400 | [diff] [blame] | 107 | |