core: use _nm_utils_ascii_str_to_bool() to parse boolean udev properties

Previously, we used nm_udev_utils_property_as_boolean(), which was
taken from g_udev_device_get_property_as_boolean(). That function
accepts "1" and "true" (with ASCII case insensitive).

When we parse a flag, there is no need to reject "no", "yes" or
"on"/"off" as invalid (and thus return FALSE). We have a boolean
parse method _nm_utils_ascii_str_to_bool(), which parses everything
that nm_udev_utils_property_as_boolean() accepts, and more.

Be liberal in what we accept, so use our general parse function.
This commit is contained in:
Thomas Haller 2021-04-23 14:40:14 +02:00
parent 3762e8f0c5
commit 48a3cebce5
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 2 additions and 2 deletions

View file

@ -1747,7 +1747,7 @@ new_default_connection(NMDevice *self)
if (dev)
uprop = udev_device_get_property_value(dev, "NM_AUTO_DEFAULT_LINK_LOCAL_ONLY");
if (nm_udev_utils_property_as_boolean(uprop)) {
if (_nm_utils_ascii_str_to_bool(uprop, FALSE)) {
setting = nm_setting_ip4_config_new();
g_object_set(setting,
NM_SETTING_IP_CONFIG_METHOD,

View file

@ -1477,7 +1477,7 @@ nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex, gboolean *unmanage
const char *value;
if (nm_platform_link_get_udev_property(self, ifindex, "NM_UNMANAGED", &value)) {
NM_SET_OUT(unmanaged, nm_udev_utils_property_as_boolean(value));
NM_SET_OUT(unmanaged, _nm_utils_ascii_str_to_bool(value, FALSE));
return TRUE;
}