Re: Problem (and the patch) when having multiple search domains on a network.



On Fri, 2005-02-11 at 13:58 +0100, Tomislav Vujec wrote:
>Hi,
>
>When the "domainName" DHCP option contains spaces, nm-named-manager
>proclaims it as invalid, although multiple domain names are often used
>in the DHCP server configuration. The attached patch fixes this
>behavior.

Tomislav, thanks for the patch.  This should already be fixed in the
latest CVS though.  Which version of NetworkManager are you using?

Index: src/NetworkManagerDHCP.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDHCP.c,v
retrieving revision 1.9
diff -u -d -r1.9 NetworkManagerDHCP.c
--- src/NetworkManagerDHCP.c	21 Jan 2005 19:32:08 -0000	1.9
+++ src/NetworkManagerDHCP.c	28 Jan 2005 23:52:01 -0000
@@ -81,31 +81,45 @@
 	}
 }
 
-static void set_domain_search (NMDevice *dev, const char *domain)
+static void set_domain_searches (NMDevice *dev, const char *searches_str)
 {
 	GError *error = NULL;
-	guint id;
+	GList *elt;
+	char **searches;
 
-	if (dev->app_data->domain_search_id
-	    && !nm_named_manager_remove_domain_search (dev->app_data->named,
-						       dev->app_data->domain_search_id,
-						       &error))
+	/* Reset our domain search list */
+	for (elt = dev->app_data->domain_search_ids; elt; elt = elt->next)
 	{
-		syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Couldn't remove domain search: %s\n", error->message);
-		g_clear_error (&error);
+		if (!nm_named_manager_remove_domain_search (dev->app_data->named,
+							    GPOINTER_TO_UINT (elt->data),
+							    &error))
+		{
+			syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Couldn't remove domain search: %s\n", error->message);
+			g_clear_error (&error);
+		}
 	}
-	
-	syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Adding domain search: %s\n", domain);
-	if ((id = nm_named_manager_add_domain_search (dev->app_data->named,
-						      domain,
-						      &error)))
-		dev->app_data->domain_search_id = id;
-	else
+	g_list_free (dev->app_data->domain_search_ids);
+	dev->app_data->domain_search_ids = NULL;
+
+	searches = g_strsplit (searches_str, " ", 0);
+
+	for (; *searches; searches++) 
 	{
-		dev->app_data->domain_search_id = 0;
-		syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Couldn't add domain search: %s\n", error->message);
-		g_clear_error (&error);
+		const char *search_elt = *searches;
+		guint id;
+
+		syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Adding domain search: %s\n", search_elt);
+		if ((id = nm_named_manager_add_domain_search (dev->app_data->named,
+							      search_elt,
+							      &error)))
+			dev->app_data->domain_search_ids = g_list_append (dev->app_data->domain_search_ids, GUINT_TO_POINTER (id));
+		else
+		{
+			syslog (LOG_ERR, G_GNUC_PRETTY_FUNCTION ": Couldn't add domain search: %s\n", error->message);
+			g_clear_error (&error);
+		}
 	}
+	g_strfreev (searches);
 }
 
 /*
@@ -148,7 +162,7 @@
 		set_nameservers (dev, dhcp_interface_get_dhcp_field (dev->dhcp_iface, dns), dhcp_interface_get_dhcp_field_len (dev->dhcp_iface, dns));
 
 	if (dhcp_interface_dhcp_field_exists (dev->dhcp_iface, domainName))
-		set_domain_search (dev, dhcp_interface_get_dhcp_field (dev->dhcp_iface, domainName));
+		set_domain_searches (dev, dhcp_interface_get_dhcp_field (dev->dhcp_iface, domainName));
 }
 
 
Index: src/NetworkManagerMain.h
===================================================================
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerMain.h,v
retrieving revision 1.8
diff -u -d -r1.8 NetworkManagerMain.h
--- src/NetworkManagerMain.h	25 Jan 2005 18:21:38 -0000	1.8
+++ src/NetworkManagerMain.h	28 Jan 2005 23:52:01 -0000
@@ -39,7 +39,7 @@
 
 	NMNamedManager			*named;
 	GList				*nameserver_ids; /* For now these are global instead of per-device */
-	guint				 domain_search_id;
+	GList				*domain_search_ids;
 
 	DBusConnection			*dbus_connection;
 	GMainContext			*main_context;
cvs server: Diffing src/backends
cvs server: Diffing test

Attachment: signature.asc
Description: This is a digitally signed message part



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