Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > d60bd1f35e0c82afb5f88d78afd23ee9 > files > 44

NetworkManager-0.7.0-9.el5.src.rpm

Index: NetworkManager-0.7.0/src/NetworkManager.c
===================================================================
--- NetworkManager-0.7.0/src/NetworkManager.c	(revision 4306)
+++ NetworkManager-0.7.0/src/NetworkManager.c	(working copy)
@@ -59,6 +59,7 @@
  */
 static NMManager *manager = NULL;
 static GMainLoop *main_loop = NULL;
+gboolean ppp_dns_workaround = FALSE;
 
 typedef struct {
 	time_t time;
@@ -223,6 +224,7 @@ main (int argc, char *argv[])
 	GOptionEntry options[] = {
 		{"no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL},
 		{"pid-file", 0, 0, G_OPTION_ARG_FILENAME, &user_pidfile, "Specify the location of a PID file", "filename"},
+		{"ppp-dns-workaround", 0, 0, G_OPTION_ARG_NONE, &ppp_dns_workaround, "Work around bogus DNS servers casued by ppp bug #1732", NULL},
 		{NULL}
 	};
 
Index: NetworkManager-0.7.0/src/nm-serial-device.c
===================================================================
--- NetworkManager-0.7.0/src/nm-serial-device.c	(revision 4306)
+++ NetworkManager-0.7.0/src/nm-serial-device.c	(working copy)
@@ -43,6 +43,7 @@
 #include "NetworkManagerUtils.h"
 
 static gboolean serial_debug = FALSE;
+extern gboolean ppp_dns_workaround;
 
 #define SERIAL_BUF_SIZE 2048
 
@@ -1007,6 +1008,44 @@ ppp_ip4_config (NMPPPManager *ppp_manage
 	NMDevice *device = NM_DEVICE (user_data);
 
 	nm_device_set_ip_iface (device, iface);
+
+	/* Work around a PPP bug (#1732) which causes many mobile broadband
+	 * providers to return 10.11.12.13 and 10.11.12.14 for the DNS servers. 
+	 * Fixed in ppp-2.4.5.
+	 *
+	 * http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=2e09ef6886bbf00bc5a9a641110f801e372ffde6
+	 * http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=f8191bf07df374f119a07910a79217c7618f113e
+	 */
+	if (ppp_dns_workaround) {
+		guint32 i, num;
+		GArray *new_dns;
+		guint32 bad_dns1 = htonl (0x0A0B0C0D);
+		guint32 good_dns1 = htonl (0x04020201);  /* GTE nameserver */
+		guint32 bad_dns2 = htonl (0x0A0B0C0E);
+		guint32 good_dns2 = htonl (0x04020202);  /* GTE nameserver */
+
+		num = nm_ip4_config_get_num_nameservers (config);
+		new_dns = g_array_sized_new (FALSE, TRUE, sizeof (guint32), num);
+
+		for (i = 0; i < num; i++) {
+			guint32 ns = nm_ip4_config_get_nameserver (config, i);
+
+			if (ns == bad_dns1)
+				g_array_append_val (new_dns, good_dns1);
+			else if (ns == bad_dns2)
+				g_array_append_val (new_dns, good_dns2);
+			else
+				g_array_append_val (new_dns, ns);
+		}
+
+		/* Clear and update nameservers with substitutions, if any */
+		nm_ip4_config_reset_nameservers (config);
+		for (i = 0; i < num; i++)
+			nm_ip4_config_add_nameserver (config, g_array_index (new_dns, guint32, i));
+
+		g_array_free (new_dns, TRUE);
+	}
+
 	NM_SERIAL_DEVICE_GET_PRIVATE (device)->pending_ip4_config = g_object_ref (config);
 	nm_device_activate_schedule_stage4_ip_config_get (device);
 }
diff -up NetworkManager-0.7.0/initscript/RedHat/NetworkManager.in.foo NetworkManager-0.7.0/initscript/RedHat/NetworkManager.in
--- NetworkManager-0.7.0/initscript/RedHat/NetworkManager.in.foo	2008-11-20 11:52:35.000000000 -0500
+++ NetworkManager-0.7.0/initscript/RedHat/NetworkManager.in	2008-11-20 11:53:26.000000000 -0500
@@ -40,7 +40,7 @@ start()
 	echo
 
 	echo -n $"Starting NetworkManager daemon: "
-	daemon --check $servicename $processname --pid-file=$pidfile
+	daemon --check $servicename $processname --pid-file=$pidfile --ppp-dns-workaround
 	RETVAL=$?
 	echo
 	if [ -n "${NETWORKWAIT}" ]; then