From ae6fe908519a87c9a2ea1b08afd852ebdb521a9c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Jun 2022 12:57:18 +0200 Subject: [PATCH] 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. --- src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 9 +++++---- 1 file 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 c0e97afe9..7c5bf11b6 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. */