ifcfg-rh: fix IP4 address fallbacks

Previous code forgot to clear a temporary variable when reading IPv4
addresses from ifcfg files, and when the value being read wasn't in the
ifcfg file, it could set wrong values in the connection for that variable
even though it didn't exist.
This commit is contained in:
Chuck Anderson
2009-01-08 12:51:13 -05:00
committed by Dan Williams
parent a10775c928
commit 3d81c82e58

View File

@@ -222,11 +222,13 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
addr = nm_ip4_address_new ();
tmp = 0;
get_one_ip4_addr (ifcfg, "IPADDR", &tmp, error);
if (*error)
goto error;
nm_ip4_address_set_address (addr, tmp);
tmp = 0;
get_one_ip4_addr (ifcfg, "GATEWAY", &tmp, error);
if (*error)
goto error;
@@ -236,6 +238,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
if (!nm_ip4_address_get_gateway (addr)) {
network_ifcfg = svNewFile (SYSCONFDIR "/sysconfig/network");
if (network_ifcfg) {
tmp = 0;
get_one_ip4_addr (network_ifcfg, "GATEWAY", &tmp, error);
svCloseFile (network_ifcfg);
if (*error)
@@ -262,6 +265,7 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
/* Fall back to NETMASK if no PREFIX was specified */
if (!nm_ip4_address_get_prefix (addr)) {
netmask = 0;
get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error);
if (*error)
goto error;