ifcfg-rh: use svUnsetAll() to clear IPv4 address properties

This commit is contained in:
Thomas Haller 2017-10-20 18:53:24 +02:00
parent 720db2ae60
commit 2e07a0f92e
3 changed files with 9 additions and 7 deletions

View file

@ -2085,13 +2085,7 @@ write_ip4_setting (NMConnection *connection,
* Some IPv4 setting related options are not cleared,
* for no strong reason. */
svUnsetValue (ifcfg, "BOOTPROTO");
for (j = -1; j < 256; j++) {
svUnsetValue (ifcfg, numbered_tag (tag, "IPADDR", j));
svUnsetValue (ifcfg, numbered_tag (tag, "PREFIX", j));
svUnsetValue (ifcfg, numbered_tag (tag, "NETMASK", j));
svUnsetValue (ifcfg, numbered_tag (tag, "GATEWAY", j));
}
svUnsetAll (ifcfg, SV_KEY_TYPE_IP4_ADDRESS);
return TRUE;
}

View file

@ -1159,6 +1159,13 @@ svUnsetAll (shvarFile *s, SvKeyType match_key_type)
|| IS_NUMBERED_TAG (line->key, "OPTIONS"))
goto do_clear;
}
if (NM_FLAGS_HAS (match_key_type, SV_KEY_TYPE_IP4_ADDRESS)) {
if ( IS_NUMBERED_TAG (line->key, "IPADDR")
|| IS_NUMBERED_TAG (line->key, "PREFIX")
|| IS_NUMBERED_TAG (line->key, "NETMASK")
|| IS_NUMBERED_TAG (line->key, "GATEWAY"))
goto do_clear;
}
continue;
do_clear:

View file

@ -89,6 +89,7 @@ gboolean svUnsetValue (shvarFile *s, const char *key);
typedef enum {
SV_KEY_TYPE_ANY = (1LL << 0),
SV_KEY_TYPE_ROUTE_SVFORMAT = (1LL << 1),
SV_KEY_TYPE_IP4_ADDRESS = (1LL << 2),
} SvKeyType;
gboolean svUnsetAll (shvarFile *s, SvKeyType match_key_type);