summaryrefslogtreecommitdiff
path: root/src/settings/plugins/ifcfg-rh/reader.c
diff options
context:
space:
mode:
authorScott Shambarger <scott-gnome@shambarger.net>2013-08-19 19:39:17 +0200
committerThomas Haller <thaller@redhat.com>2013-09-05 21:13:15 +0200
commit04f6e09d5082acaceef2329675d8470cf23f202f (patch)
treebe6d407668256a6b13a0af2326429f9b9cfbd53e /src/settings/plugins/ifcfg-rh/reader.c
parentf6703f540c7186f7d6c3e0c8498a2c424d87c8e8 (diff)
downloadNetworkManager-04f6e09d5082acaceef2329675d8470cf23f202f.tar.gz
ifcfg-rh: fix handling of legacy IPv4 route files without gateway.
Routes without gateway are legal and should be treated as a device route (direct route). https://bugzilla.gnome.org/show_bug.cgi?id=697525 The original patch was written by Scott Shambarger <scott-gnome@shambarger.net>. This is a modified version of the patch. Signed-off-by: Thomas Haller <thaller@redhat.com> Reported-by: Scott Shambarger <scott-gnome@shambarger.net>
Diffstat (limited to 'src/settings/plugins/ifcfg-rh/reader.c')
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 50361ed051..6b0c6933e5 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -859,7 +859,7 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
GMatchInfo *match_info;
NMIP4Route *route;
guint32 ip4_addr;
- char *dest = NULL, *prefix = NULL, *next_hop = NULL, *metric = NULL;
+ char *dest = NULL, *prefix = NULL, *metric = NULL;
long int prefix_int, metric_int;
gboolean success = FALSE;
@@ -942,22 +942,23 @@ read_route_file_legacy (const char *filename, NMSettingIP4Config *s_ip4, GError
/* Next hop */
g_regex_match (regex_via, *iter, 0, &match_info);
- if (!g_match_info_matches (match_info)) {
- g_match_info_free (match_info);
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Missing IP4 route gateway address in record: '%s'", *iter);
- goto error;
- }
- next_hop = g_match_info_fetch (match_info, 1);
- g_match_info_free (match_info);
- if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) {
- g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
- "Invalid IP4 route gateway address '%s'", next_hop);
+ if (g_match_info_matches (match_info)) {
+ char *next_hop = g_match_info_fetch (match_info, 1);
+ if (inet_pton (AF_INET, next_hop, &ip4_addr) != 1) {
+ g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
+ "Invalid IP4 route gateway address '%s'",
+ next_hop);
+ g_match_info_free (match_info);
+ g_free (next_hop);
+ goto error;
+ }
g_free (next_hop);
- goto error;
+ } else {
+ /* we don't make distinction between missing GATEWAY IP and 0.0.0.0 */
+ ip4_addr = 0;
}
nm_ip4_route_set_next_hop (route, ip4_addr);
- g_free (next_hop);
+ g_match_info_free (match_info);
/* Metric */
g_regex_match (regex_metric, *iter, 0, &match_info);