summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-06-24 12:57:18 +0200
committerThomas Haller <thaller@redhat.com>2022-06-27 08:29:27 +0200
commitae6fe908519a87c9a2ea1b08afd852ebdb521a9c (patch)
treef610a7fbdeba55a5cf63f5be09d23462249ec618
parentefca0b8fa640a8490c43cef9b03fd92b6c149180 (diff)
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.c9
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. */