summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bb1d857)
raw | patch | inline | side by side (parent: bb1d857)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 11 Dec 2016 11:06:58 +0000 (12:06 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 11 Dec 2016 11:17:58 +0000 (12:17 +0100) |
For the network plugin, this was changed in ac73c75aed7 (which landed in 5.6)
which was a backward incompatible change breaking user configuration. Adding
support back in a central location ensures a more consistent behavior across
plugins. At the same time, we issue a warning message that this behavior is
deprecated.
GH #2083, #2098
which was a backward incompatible change breaking user configuration. Adding
support back in a central location ensures a more consistent behavior across
plugins. At the same time, we issue a warning message that this behavior is
deprecated.
GH #2083, #2098
src/daemon/configfile.c | patch | blob | history |
index d5f01e077937934b39b046a4829ec928da9e0c50..3934e1f9dba546d2c8a2ed0f1a85ccac730048f8 100644 (file)
--- a/src/daemon/configfile.c
+++ b/src/daemon/configfile.c
@@ -1119,14 +1119,36 @@ int cf_util_get_boolean(const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */
if ((ci == NULL) || (ret_bool == NULL))
return (EINVAL);
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
+ if ((ci->values_num != 1) || ((ci->values[0].type != OCONFIG_TYPE_BOOLEAN) &&
+ (ci->values[0].type != OCONFIG_TYPE_STRING))) {
ERROR("cf_util_get_boolean: The %s option requires "
"exactly one boolean argument.",
ci->key);
return (-1);
}
- *ret_bool = ci->values[0].value.boolean ? 1 : 0;
+ switch (ci->values[0].type) {
+ case OCONFIG_TYPE_BOOLEAN:
+ *ret_bool = ci->values[0].value.boolean ? 1 : 0;
+ break;
+ case OCONFIG_TYPE_STRING:
+ WARNING("cf_util_get_boolean: Using string value `%s' for boolean option "
+ "`%s' is deprecated and will be removed in future releases. "
+ "Use unquoted true or false instead.",
+ ci->values[0].value.string, ci->key);
+
+ if (IS_TRUE(ci->values[0].value.string))
+ *ret_bool = 1;
+ else if (IS_FALSE(ci->values[0].value.string))
+ *ret_bool = 0;
+ else {
+ ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' "
+ "option as a boolean value.",
+ ci->values[0].value.string, ci->key);
+ return (-1);
+ }
+ break;
+ }
return (0);
} /* }}} int cf_util_get_boolean */