[patch 3/3] multiple named zones



This patch brings support for multiple domains in named configuration. All listed
domains in the IP4 config structure are processed as follows:
- domain is added to 'search' entry in /etc/resolv.conf, as before;
- 'SetForwarders' message is sent to named for each nameserver listed in the IP4
config.

Index: NetworkManager-cvs/src/named-manager/nm-named-manager.c
===================================================================
--- NetworkManager-cvs.orig/src/named-manager/nm-named-manager.c	2006-10-12 18:03:19.000000000 +0200
+++ NetworkManager-cvs/src/named-manager/nm-named-manager.c	2006-10-12 22:41:27.000000000 +0200
@@ -409,7 +409,7 @@ lose:
 }
 
 static const char *
-get_domain_for_config (NMIP4Config *config, gboolean *dflt)
+get_domain_for_config (NMIP4Config *config, int rank, gboolean *dflt)
 {
 	gboolean is_dflt = FALSE;
 	const char *domain;
@@ -426,7 +426,7 @@ get_domain_for_config (NMIP4Config *conf
 	if (is_dflt)
 		domain = ".";	/* Default domain */
 	else
-		domain = nm_ip4_config_get_domain (config, 0);
+		domain = nm_ip4_config_get_domain (config, rank);
 
 	if (dflt)
 		*dflt = is_dflt;
@@ -435,20 +435,12 @@ get_domain_for_config (NMIP4Config *conf
 }
 
 static gboolean
-add_ip4_config_to_named (NMNamedManager *mgr, NMIP4Config *config)
+add_one_zone_to_named (NMNamedManager *mgr, NMIP4Config *config, const char *domain, gboolean dflt)
 {
-	const char *domain;
 	int i, num_nameservers;
 	DBusMessage *	message;
 	DBusMessage *	reply;
 	DBusError		error;
-	gboolean		dflt = FALSE;
-
-	g_return_val_if_fail (mgr != NULL, FALSE);
-	g_return_val_if_fail (config != NULL, FALSE);
-
-	if (!(domain = get_domain_for_config (config, &dflt)))
-		return FALSE;
 
 	if (!(message = dbus_message_new_method_call (NAMED_DBUS_SERVICE, NAMED_DBUS_PATH, NAMED_DBUS_INTERFACE, "SetForwarders")))
 		return FALSE;
@@ -500,6 +492,35 @@ add_ip4_config_to_named (NMNamedManager 
 }
 
 static gboolean
+add_ip4_config_to_named (NMNamedManager *mgr, NMIP4Config *config)
+{
+	const char *domain;
+	int i, num_domains;
+	gboolean		dflt = FALSE;
+
+	g_return_val_if_fail (mgr != NULL, FALSE);
+	g_return_val_if_fail (config != NULL, FALSE);
+
+	num_domains = nm_ip4_config_get_num_domains (config);
+	if (num_domains) {
+	    for (i = 0; i < num_domains; i++) {
+		if (!(domain = get_domain_for_config (config, i, &dflt)))
+		    return FALSE;
+		if (!add_one_zone_to_named (mgr, config, domain, dflt))
+		    return FALSE;
+	    }
+	} else {
+	    if (!(domain = get_domain_for_config (config, 0, &dflt)))
+		return FALSE;
+
+	    return
+		add_one_zone_to_named (mgr, config, domain, dflt);
+	}
+
+	return TRUE;
+}
+
+static gboolean
 add_all_ip4_configs_to_named (NMNamedManager *mgr)
 {
 	GSList *elt = NULL;
@@ -562,14 +583,27 @@ static gboolean
 remove_ip4_config_from_named (NMNamedManager *mgr, NMIP4Config *config)
 {
 	const char *domain;
-
+	int i, num_domains;
 	g_return_val_if_fail (mgr != NULL, FALSE);
 	g_return_val_if_fail (config != NULL, FALSE);
 
-	if (!(domain = get_domain_for_config (config, NULL)))
+	num_domains = nm_ip4_config_get_num_domains (config);
+	if (num_domains) {
+	    for (i = 0; i < num_domains; i++) {
+		if (!(domain = get_domain_for_config (config, i, NULL)))
+		    return FALSE;
+
+		if (!remove_one_zone_from_named (mgr, domain))
+		    return FALSE;
+	    }
+	} else {
+	    if (!(domain = get_domain_for_config (config, 0, NULL)))
 		return FALSE;
 
-	return remove_one_zone_from_named (mgr, domain);
+	    return remove_one_zone_from_named (mgr, domain);
+	}
+
+	return TRUE;
 }
 
 static void
@@ -687,7 +721,7 @@ get_last_default_domain (NMNamedManager 
 		NMIP4Config *config = (NMIP4Config *)(elt->data);
 
 		last = config;
-		domain = get_domain_for_config (config, &dflt);
+		domain = get_domain_for_config (config, 0, &dflt);
 		if (dflt)
 			last_default = config;
 	}

--
-gr0n6-

"Anarchy is about taking complete responsibility for yourself."
        Alan Moore.




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