diff options
author | Thomas Haller <thaller@redhat.com> | 2022-06-24 12:57:18 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-06-27 08:29:27 +0200 |
commit | ae6fe908519a87c9a2ea1b08afd852ebdb521a9c (patch) | |
tree | f610a7fbdeba55a5cf63f5be09d23462249ec618 | |
parent | efca0b8fa640a8490c43cef9b03fd92b6c149180 (diff) | |
download | NetworkManager-ae6fe908519a87c9a2ea1b08afd852ebdb521a9c.tar.gz |
ifcfg-rh: fix serializing lock route attributes
The lock attribute is a boolean, it can also be FALSE. We need
to handle that case, and don't add serialize "$NAME lock 0" for them.
-rw-r--r-- | src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index c0e97afe96..7c5bf11b6e 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -2295,7 +2295,8 @@ static char * get_route_attributes_string(NMIPRoute *route, int family) { gs_free const char **names = NULL; - GVariant *attr, *lock; + GVariant *attr; + GVariant *lock; GString *str; guint i, len; @@ -2338,9 +2339,9 @@ get_route_attributes_string(NMIPRoute *route, int family) } else if (NM_STR_HAS_PREFIX(names[i], "lock-")) { const char *n = &(names[i])[NM_STRLEN("lock-")]; - attr = nm_ip_route_get_attribute(route, n); - if (!attr) { - g_string_append_printf(str, "%s lock 0", n); + if (!nm_ip_route_get_attribute(route, n)) { + if (g_variant_get_boolean(attr)) + g_string_append_printf(str, "%s lock 0", n); } else { /* we also have a corresponding attribute with the numeric value. The * lock setting is handled above. */ |