diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 8e174bd56b..4a5ca1d186 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -368,6 +368,14 @@ svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 m */ void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim) +{ + svSetValueFull (s, key, value && value[0] ? value : NULL, verbatim); +} + +/* Same as svSetValue() but it preserves empty @value -- contrary to + * svSetValue() for which "" effectively means to remove the value. */ +void +svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim) { gs_free char *newval_free = NULL; gs_free char *oldval = NULL; @@ -384,7 +392,7 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim) newval = svEscape (value, &newval_free); oldval = svGetValueFull (s, key, FALSE); - if (!newval || !newval[0]) { + if (!newval) { /* delete value */ if (oldval) { /* delete line */ diff --git a/src/settings/plugins/ifcfg-rh/shvar.h b/src/settings/plugins/ifcfg-rh/shvar.h index 738bce6d11..4902541b00 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.h +++ b/src/settings/plugins/ifcfg-rh/shvar.h @@ -72,6 +72,7 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g * to the top of the file. */ void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim); +void svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim); /* Write the current contents iff modified. Returns FALSE on error