Commit fab24161 authored by Dan Williams's avatar Dan Williams

2008-07-27 Dan Williams <dcbw@redhat.com>

	* system-settings/plugins/ifcfg-fedora/reader.c
		- (make_ip4_setting): fix parsing automatic configs



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3858 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 65d53383
2008-07-27 Dan Williams <dcbw@redhat.com>
* system-settings/plugins/ifcfg-fedora/reader.c
- (make_ip4_setting): fix parsing automatic configs
2008-07-27 Dan Williams <dcbw@redhat.com> 2008-07-27 Dan Williams <dcbw@redhat.com>
* src/dnsmasq-manager/nm-dnsmasq-manager.c * src/dnsmasq-manager/nm-dnsmasq-manager.c
......
...@@ -179,56 +179,59 @@ make_ip4_setting (shvarFile *ifcfg, GError **error) ...@@ -179,56 +179,59 @@ make_ip4_setting (shvarFile *ifcfg, GError **error)
g_free (value); g_free (value);
get_one_ip4_addr (ifcfg, "IPADDR", &tmp.address, error); /* Handle manual settings */
if (*error) if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
goto error; get_one_ip4_addr (ifcfg, "IPADDR", &tmp.address, error);
if (*error)
goto error;
get_one_ip4_addr (ifcfg, "GATEWAY", &tmp.gateway, error); get_one_ip4_addr (ifcfg, "GATEWAY", &tmp.gateway, error);
if (*error) if (*error)
goto error; goto error;
/* If no gateway in the ifcfg, try /etc/sysconfig/network instead */ /* If no gateway in the ifcfg, try /etc/sysconfig/network instead */
if (!tmp.gateway) { if (!tmp.gateway) {
shvarFile *network; shvarFile *network;
network = svNewFile ("/etc/sysconfig/network"); network = svNewFile ("/etc/sysconfig/network");
if (network) { if (network) {
get_one_ip4_addr (network, "GATEWAY", &tmp.gateway, error); get_one_ip4_addr (network, "GATEWAY", &tmp.gateway, error);
svCloseFile (network); svCloseFile (network);
if (*error) if (*error)
goto error; goto error;
}
} }
}
value = svGetValue (ifcfg, "PREFIX"); value = svGetValue (ifcfg, "PREFIX");
if (value) { if (value) {
long int prefix; long int prefix;
errno = 0; errno = 0;
prefix = strtol (value, NULL, 10); prefix = strtol (value, NULL, 10);
if (errno || prefix <= 0 || prefix > 32) { if (errno || prefix <= 0 || prefix > 32) {
g_set_error (error, ifcfg_plugin_error_quark (), 0, g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid IP4 prefix '%s'", value); "Invalid IP4 prefix '%s'", value);
g_free (value);
goto error;
}
tmp.prefix = (guint32) prefix;
g_free (value); g_free (value);
goto error;
} }
tmp.prefix = (guint32) prefix;
g_free (value);
}
/* Fall back to NETMASK if no PREFIX was specified */ /* Fall back to NETMASK if no PREFIX was specified */
if (!tmp.prefix) { if (!tmp.prefix) {
get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error); get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error);
if (*error) if (*error)
goto error; goto error;
tmp.prefix = nm_utils_ip4_netmask_to_prefix (netmask); tmp.prefix = nm_utils_ip4_netmask_to_prefix (netmask);
} }
/* Validate the prefix */ /* Validate the prefix */
if (!tmp.prefix || tmp.prefix > 32) { if (!tmp.prefix || tmp.prefix > 32) {
g_set_error (error, ifcfg_plugin_error_quark (), 0, g_set_error (error, ifcfg_plugin_error_quark (), 0,
"Invalid IP4 prefix '%d'", tmp.prefix); "Invalid IP4 prefix '%d'", tmp.prefix);
goto error; goto error;
}
} }
/* Yay, let's make an IP4 config */ /* Yay, let's make an IP4 config */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment