[PATCH] ifupdown plugin - add more ip4 default settings for gateway et al



Implement more graceful ip4 config parsing for cases where
/etc/network/interfaces omits basic ip4 settings, such as gateway etc.

 - Alexander

=== modified file 'ChangeLog'
--- ChangeLog	2008-09-30 16:48:16 +0000
+++ ChangeLog	2008-10-01 20:28:12 +0000
@@ -1,8 +1,15 @@
+2008-10-01  Alexander Sack  <asac ubuntu com>
+
+	Implement more graceful ip4 config parsing for cases where
+	/etc/network/interfaces omits basic ip4 settings, such as gateway etc.
+	* system-settings/plugins/ifupdown/parser.c
+		- Use default values for address, netmask/prefix and gateway.
+
 2008-09-30  Dan Williams  <dcbw redhat com>
 
 	* src/NetworkManagerPolicy.c
 		- (lookup_thread_worker): don't store the idle handler ID becuase the
 			idle handler could have already run and freed the LookupThread
 			structure
 
 2008-09-30  Tambet Ingo  <tambet gmail com>

=== modified file 'system-settings/plugins/ifupdown/parser.c'
--- system-settings/plugins/ifupdown/parser.c	2008-09-18 15:29:59 +0000
+++ system-settings/plugins/ifupdown/parser.c	2008-10-01 20:28:12 +0000
@@ -422,26 +422,36 @@ update_ip4_setting_from_if_block(NMConne
 		GSList* nameservers_list_i = NULL;
 		GError *error = NULL;
 
 		if(nameservers_v)
 			nameservers_list_i = nameservers_list = string_to_glist_of_strings (nameservers_v);
 		if(nameserver_v)
 			nameservers_list_i = nameservers_list = g_slist_append(nameservers_list, g_strdup(nameserver_v));
 
+		if (!address_v)
+			address_v = g_strdup ("0.0.0.0");
+
 		if (inet_pton (AF_INET, address_v, &tmp_ip4_addr))
 			ip4config->address = tmp_ip4_addr.s_addr;
 		else
 			g_set_error (&error, eni_plugin_error_quark (), 0,
 					   "Invalid %s IP4 address '%s'", "address", address_v);
+		if (!netmask_v)
+			netmask_v = g_strdup( "255.255.255.255");
+
 		if (inet_pton (AF_INET, netmask_v, &tmp_ip4_addr))
 			ip4config->prefix = nm_utils_ip4_netmask_to_prefix(tmp_ip4_addr.s_addr);
 		else
 			g_set_error (&error, eni_plugin_error_quark (), 0,
 					   "Invalid %s IP4 address '%s'", "netmask", netmask_v);
+
+		if (!gateway_v)
+			gateway_v = g_strdup (address_v);
+
 		if (inet_pton (AF_INET, gateway_v, &tmp_ip4_addr))
 			ip4config->gateway = tmp_ip4_addr.s_addr;
 		else
 			g_set_error (&error, eni_plugin_error_quark (), 0,
 					   "Invalid %s IP4 address '%s'", "gateway", gateway_v);
 
 		ip4_addresses = g_slist_append(ip4_addresses, ip4config);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]