mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 04:58:01 +02:00
libnm: be more accepting parsing boolean values in nm_utils_parse_variant_attributes()
We should use the same str2bool parser everywhere: _nm_utils_ascii_str_to_bool().
Incidentally, this function allows more forms of expressing a boolean
value.
$ nmcli connection modify "$CON" ipv4.routes '1.2.3.4/32 1.2.3.1 onlink=1'
Error: failed to modify ipv4.routes: invalid option 'onlink=1': invalid boolean value '1' for attribute 'onlink'.
(cherry picked from commit 26e7abc65e)
This commit is contained in:
parent
00bc168307
commit
3b1be2b4cd
1 changed files with 3 additions and 6 deletions
|
|
@ -4688,13 +4688,10 @@ nm_utils_parse_variant_attributes (const char *string,
|
||||||
}
|
}
|
||||||
variant = g_variant_new_byte ((guchar) num);
|
variant = g_variant_new_byte ((guchar) num);
|
||||||
} else if (g_variant_type_equal ((*s)->type, G_VARIANT_TYPE_BOOLEAN)) {
|
} else if (g_variant_type_equal ((*s)->type, G_VARIANT_TYPE_BOOLEAN)) {
|
||||||
gboolean b;
|
int b;
|
||||||
|
|
||||||
if (nm_streq (value, "true"))
|
b = _nm_utils_ascii_str_to_bool (value, -1);
|
||||||
b = TRUE;
|
if (b == -1) {
|
||||||
else if (nm_streq (value, "false"))
|
|
||||||
b = FALSE;
|
|
||||||
else {
|
|
||||||
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED,
|
||||||
_("invalid boolean value '%s' for attribute '%s'"), value, name);
|
_("invalid boolean value '%s' for attribute '%s'"), value, name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue