diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-04-26 20:26:07 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-04-27 17:24:23 +0200 |
commit | 9e668595fee2127c20310f50e405cd3450f88f5b (patch) | |
tree | bef59d7016477cc28dd28154df3f5ffa0298a9a4 | |
parent | 38fbcdf0e5fd0b8d765aebe06e452ca0a7df4a84 (diff) | |
download | NetworkManager-9e668595fee2127c20310f50e405cd3450f88f5b.tar.gz |
ifcfg-rh: preserve the archaic NETMASK key
py-kickstart writes this out and there apparently are users using this.
Let them have one less problem.
Co-Authored-By: Thomas Haller <thaller@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1445414
-rw-r--r-- | src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index a670ba5d1e..c6957e8816 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -2102,6 +2102,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) */ for (i = n = 0; i < num; i++) { NMIPAddress *addr; + guint prefix; addr = nm_setting_ip_config_get_address (s_ip4, i); @@ -2131,9 +2132,18 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) } svSetValueStr (ifcfg, addr_key, nm_ip_address_get_address (addr)); - svSetValueInt64 (ifcfg, prefix_key, nm_ip_address_get_prefix (addr)); - svUnsetValue (ifcfg, netmask_key); + prefix = nm_ip_address_get_prefix (addr); + svSetValueInt64 (ifcfg, prefix_key, prefix); + + /* If the legacy "NETMASK" is present, keep it. */ + if (svGetValue (ifcfg, netmask_key, &tmp)) { + char buf[INET_ADDRSTRLEN]; + + g_free (tmp); + svSetValueStr (ifcfg, netmask_key, nm_utils_inet4_ntop (prefix, buf)); + } + svUnsetValue (ifcfg, gw_key); n++; } |