From fab2416151db6ba1459aaea96b79a025815006f3 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 27 Jul 2008 20:00:13 +0000 Subject: [PATCH] 2008-07-27 Dan Williams * 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 --- ChangeLog | 5 + system-settings/plugins/ifcfg-fedora/reader.c | 97 ++++++++++--------- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bd2ed1239..522d1d722d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-27 Dan Williams + + * system-settings/plugins/ifcfg-fedora/reader.c + - (make_ip4_setting): fix parsing automatic configs + 2008-07-27 Dan Williams * src/dnsmasq-manager/nm-dnsmasq-manager.c diff --git a/system-settings/plugins/ifcfg-fedora/reader.c b/system-settings/plugins/ifcfg-fedora/reader.c index 4ea5c23aca..43cbc79997 100644 --- a/system-settings/plugins/ifcfg-fedora/reader.c +++ b/system-settings/plugins/ifcfg-fedora/reader.c @@ -179,56 +179,59 @@ make_ip4_setting (shvarFile *ifcfg, GError **error) g_free (value); - get_one_ip4_addr (ifcfg, "IPADDR", &tmp.address, error); - if (*error) - goto error; - - get_one_ip4_addr (ifcfg, "GATEWAY", &tmp.gateway, error); - if (*error) - goto error; - - /* If no gateway in the ifcfg, try /etc/sysconfig/network instead */ - if (!tmp.gateway) { - shvarFile *network; - - network = svNewFile ("/etc/sysconfig/network"); - if (network) { - get_one_ip4_addr (network, "GATEWAY", &tmp.gateway, error); - svCloseFile (network); - if (*error) - goto error; - } - } - - value = svGetValue (ifcfg, "PREFIX"); - if (value) { - long int prefix; - - errno = 0; - prefix = strtol (value, NULL, 10); - if (errno || prefix <= 0 || prefix > 32) { - g_set_error (error, ifcfg_plugin_error_quark (), 0, - "Invalid IP4 prefix '%s'", value); - g_free (value); - goto error; - } - tmp.prefix = (guint32) prefix; - g_free (value); - } - - /* Fall back to NETMASK if no PREFIX was specified */ - if (!tmp.prefix) { - get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error); + /* Handle manual settings */ + if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) { + get_one_ip4_addr (ifcfg, "IPADDR", &tmp.address, error); if (*error) goto error; - tmp.prefix = nm_utils_ip4_netmask_to_prefix (netmask); - } - /* Validate the prefix */ - if (!tmp.prefix || tmp.prefix > 32) { - g_set_error (error, ifcfg_plugin_error_quark (), 0, - "Invalid IP4 prefix '%d'", tmp.prefix); - goto error; + get_one_ip4_addr (ifcfg, "GATEWAY", &tmp.gateway, error); + if (*error) + goto error; + + /* If no gateway in the ifcfg, try /etc/sysconfig/network instead */ + if (!tmp.gateway) { + shvarFile *network; + + network = svNewFile ("/etc/sysconfig/network"); + if (network) { + get_one_ip4_addr (network, "GATEWAY", &tmp.gateway, error); + svCloseFile (network); + if (*error) + goto error; + } + } + + value = svGetValue (ifcfg, "PREFIX"); + if (value) { + long int prefix; + + errno = 0; + prefix = strtol (value, NULL, 10); + if (errno || prefix <= 0 || prefix > 32) { + g_set_error (error, ifcfg_plugin_error_quark (), 0, + "Invalid IP4 prefix '%s'", value); + g_free (value); + goto error; + } + tmp.prefix = (guint32) prefix; + g_free (value); + } + + /* Fall back to NETMASK if no PREFIX was specified */ + if (!tmp.prefix) { + get_one_ip4_addr (ifcfg, "NETMASK", &netmask, error); + if (*error) + goto error; + tmp.prefix = nm_utils_ip4_netmask_to_prefix (netmask); + } + + /* Validate the prefix */ + if (!tmp.prefix || tmp.prefix > 32) { + g_set_error (error, ifcfg_plugin_error_quark (), 0, + "Invalid IP4 prefix '%d'", tmp.prefix); + goto error; + } } /* Yay, let's make an IP4 config */