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:

committed by
Dan Williams

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