|
|
ebef98 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
ebef98 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
ebef98 |
Date: Mon, 4 Oct 2021 16:52:55 -0500
|
|
|
ebef98 |
Subject: [PATCH] libmultipath: cleanup invalid config handling
|
|
|
ebef98 |
|
|
|
ebef98 |
Add error reporting to the remaining config handlers. If the value is
|
|
|
ebef98 |
invalid, do not change the existing config option's value. Also print
|
|
|
ebef98 |
an error whenever 0 is returned for an invalid value. When the handler
|
|
|
ebef98 |
returns 1, config processing already fails with an error message.
|
|
|
ebef98 |
|
|
|
ebef98 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
ebef98 |
---
|
|
|
ebef98 |
libmultipath/dict.c | 73 +++++++++++++++++++++++++++++++--------------
|
|
|
ebef98 |
1 file changed, 51 insertions(+), 22 deletions(-)
|
|
|
ebef98 |
|
|
|
ebef98 |
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
|
|
|
ebef98 |
index 68647061..c534d703 100644
|
|
|
ebef98 |
--- a/libmultipath/dict.c
|
|
|
ebef98 |
+++ b/libmultipath/dict.c
|
|
|
ebef98 |
@@ -199,8 +199,11 @@ set_yes_no(vector strvec, void *ptr, const char *file, int line_nr)
|
|
|
ebef98 |
|
|
|
ebef98 |
if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
|
|
|
ebef98 |
*int_ptr = YN_YES;
|
|
|
ebef98 |
- else
|
|
|
ebef98 |
+ else if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0)
|
|
|
ebef98 |
*int_ptr = YN_NO;
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for %s: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -221,7 +224,8 @@ set_yes_no_undef(vector strvec, void *ptr, const char *file, int line_nr)
|
|
|
ebef98 |
else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
|
|
|
ebef98 |
*int_ptr = YNU_YES;
|
|
|
ebef98 |
else
|
|
|
ebef98 |
- *int_ptr = YNU_UNDEF;
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for %s: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, (char*)VECTOR_SLOT(strvec, 0), buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -480,9 +484,6 @@ def_find_multipaths_handler(struct config *conf, vector strvec,
|
|
|
ebef98 |
char *buff;
|
|
|
ebef98 |
int i;
|
|
|
ebef98 |
|
|
|
ebef98 |
- if (set_yes_no_undef(strvec, &conf->find_multipaths, file, line_nr) == 0 && conf->find_multipaths != FIND_MULTIPATHS_UNDEF)
|
|
|
ebef98 |
- return 0;
|
|
|
ebef98 |
-
|
|
|
ebef98 |
buff = set_value(strvec);
|
|
|
ebef98 |
if (!buff)
|
|
|
ebef98 |
return 1;
|
|
|
ebef98 |
@@ -495,9 +496,14 @@ def_find_multipaths_handler(struct config *conf, vector strvec,
|
|
|
ebef98 |
}
|
|
|
ebef98 |
}
|
|
|
ebef98 |
|
|
|
ebef98 |
- if (conf->find_multipaths == YNU_UNDEF) {
|
|
|
ebef98 |
- condlog(0, "illegal value for find_multipaths: %s", buff);
|
|
|
ebef98 |
- conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
|
|
|
ebef98 |
+ if (i >= __FIND_MULTIPATHS_LAST) {
|
|
|
ebef98 |
+ if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0)
|
|
|
ebef98 |
+ conf->find_multipaths = FIND_MULTIPATHS_OFF;
|
|
|
ebef98 |
+ else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
|
|
|
ebef98 |
+ conf->find_multipaths = FIND_MULTIPATHS_ON;
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for find_multipaths: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
}
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
@@ -546,8 +552,10 @@ static int uid_attrs_handler(struct config *conf, vector strvec,
|
|
|
ebef98 |
if (!val)
|
|
|
ebef98 |
return 1;
|
|
|
ebef98 |
if (parse_uid_attrs(val, conf))
|
|
|
ebef98 |
- condlog(1, "error parsing uid_attrs: \"%s\"", val);
|
|
|
ebef98 |
- condlog(3, "parsed %d uid_attrs", VECTOR_SIZE(&conf->uid_attrs));
|
|
|
ebef98 |
+ condlog(1, "%s line %d,error parsing uid_attrs: \"%s\"", file,
|
|
|
ebef98 |
+ line_nr, val);
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(4, "parsed %d uid_attrs", VECTOR_SIZE(&conf->uid_attrs));
|
|
|
ebef98 |
FREE(val);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
}
|
|
|
ebef98 |
@@ -775,8 +783,11 @@ def_config_dir_handler(struct config *conf, vector strvec, const char *file,
|
|
|
ebef98 |
int line_nr)
|
|
|
ebef98 |
{
|
|
|
ebef98 |
/* this is only valid in the main config file */
|
|
|
ebef98 |
- if (conf->processed_main_config)
|
|
|
ebef98 |
+ if (conf->processed_main_config) {
|
|
|
ebef98 |
+ condlog(1, "%s line %d, config_dir option only valid in /etc/multipath.conf",
|
|
|
ebef98 |
+ file, line_nr);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
+ }
|
|
|
ebef98 |
condlog(2, "%s line %d, \"config_dir\" is deprecated and will be disabled in a future release",
|
|
|
ebef98 |
file, line_nr);
|
|
|
ebef98 |
return set_path(strvec, &conf->config_dir, file, line_nr);
|
|
|
ebef98 |
@@ -836,7 +847,9 @@ set_mode(vector strvec, void *ptr, int *flags, const char *file, int line_nr)
|
|
|
ebef98 |
if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
|
|
|
ebef98 |
*flags |= (1 << ATTR_MODE);
|
|
|
ebef98 |
*mode_ptr = mode;
|
|
|
ebef98 |
- }
|
|
|
ebef98 |
+ } else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for mode: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -861,7 +874,9 @@ set_uid(vector strvec, void *ptr, int *flags, const char *file, int line_nr)
|
|
|
ebef98 |
else if (sscanf(buff, "%u", &uid) == 1){
|
|
|
ebef98 |
*flags |= (1 << ATTR_UID);
|
|
|
ebef98 |
*uid_ptr = uid;
|
|
|
ebef98 |
- }
|
|
|
ebef98 |
+ } else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for uid: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -887,7 +902,9 @@ set_gid(vector strvec, void *ptr, int *flags, const char *file, int line_nr)
|
|
|
ebef98 |
else if (sscanf(buff, "%u", &gid) == 1){
|
|
|
ebef98 |
*flags |= (1 << ATTR_GID);
|
|
|
ebef98 |
*gid_ptr = gid;
|
|
|
ebef98 |
- }
|
|
|
ebef98 |
+ } else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for gid: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
}
|
|
|
ebef98 |
@@ -989,7 +1006,8 @@ set_dev_loss(vector strvec, void *ptr, const char *file, int line_nr)
|
|
|
ebef98 |
if (!strcmp(buff, "infinity"))
|
|
|
ebef98 |
*uint_ptr = MAX_DEV_LOSS_TMO;
|
|
|
ebef98 |
else if (sscanf(buff, "%u", uint_ptr) != 1)
|
|
|
ebef98 |
- *uint_ptr = DEV_LOSS_TMO_UNSET;
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for dev_loss_tmo: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -1023,13 +1041,19 @@ static int
|
|
|
ebef98 |
set_pgpolicy(vector strvec, void *ptr, const char *file, int line_nr)
|
|
|
ebef98 |
{
|
|
|
ebef98 |
char * buff;
|
|
|
ebef98 |
+ int policy;
|
|
|
ebef98 |
int *int_ptr = (int *)ptr;
|
|
|
ebef98 |
|
|
|
ebef98 |
buff = set_value(strvec);
|
|
|
ebef98 |
if (!buff)
|
|
|
ebef98 |
return 1;
|
|
|
ebef98 |
|
|
|
ebef98 |
- *int_ptr = get_pgpolicy_id(buff);
|
|
|
ebef98 |
+ policy = get_pgpolicy_id(buff);
|
|
|
ebef98 |
+ if (policy != IOPOLICY_UNDEF)
|
|
|
ebef98 |
+ *int_ptr = policy;
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for path_grouping_policy: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -1142,10 +1166,11 @@ set_rr_weight(vector strvec, void *ptr, const char *file, int line_nr)
|
|
|
ebef98 |
|
|
|
ebef98 |
if (!strcmp(buff, "priorities"))
|
|
|
ebef98 |
*int_ptr = RR_WEIGHT_PRIO;
|
|
|
ebef98 |
-
|
|
|
ebef98 |
- if (!strcmp(buff, "uniform"))
|
|
|
ebef98 |
+ else if (!strcmp(buff, "uniform"))
|
|
|
ebef98 |
*int_ptr = RR_WEIGHT_NONE;
|
|
|
ebef98 |
-
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for rr_weight: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -1281,10 +1306,13 @@ def_log_checker_err_handler(struct config *conf, vector strvec,
|
|
|
ebef98 |
if (!buff)
|
|
|
ebef98 |
return 1;
|
|
|
ebef98 |
|
|
|
ebef98 |
- if (strlen(buff) == 4 && !strcmp(buff, "once"))
|
|
|
ebef98 |
+ if (!strcmp(buff, "once"))
|
|
|
ebef98 |
conf->log_checker_err = LOG_CHKR_ERR_ONCE;
|
|
|
ebef98 |
- else if (strlen(buff) == 6 && !strcmp(buff, "always"))
|
|
|
ebef98 |
+ else if (!strcmp(buff, "always"))
|
|
|
ebef98 |
conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
|
|
|
ebef98 |
+ else
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for log_checker_err: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
|
|
|
ebef98 |
free(buff);
|
|
|
ebef98 |
return 0;
|
|
|
ebef98 |
@@ -1545,7 +1573,8 @@ hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file,
|
|
|
ebef98 |
goto out;
|
|
|
ebef98 |
}
|
|
|
ebef98 |
}
|
|
|
ebef98 |
- hwe->vpd_vendor_id = 0;
|
|
|
ebef98 |
+ condlog(1, "%s line %d, invalid value for vpd_vendor: \"%s\"",
|
|
|
ebef98 |
+ file, line_nr, buff);
|
|
|
ebef98 |
out:
|
|
|
ebef98 |
FREE(buff);
|
|
|
ebef98 |
return 0;
|