[patch]NIS support



Hi,

 This patch support the NIS configuration, and I don't expand the
NMIP4ConfigPrivate for the nis_domain, nis_servers. For simple, just
use g_object_set_data_full to bind the data with the ip4_config
object.

Sincerely Yours,

Bin Li

http://cn.opensuse.org
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 5cebaa8..9e32403 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -891,6 +891,18 @@ ip4_options_to_config (NMDHCPClient *self)
 			nm_ip4_config_set_mtu (ip4_config, int_mtu);
 	}
 
+	str = g_hash_table_lookup (priv->options, "new_nis_domain");
+	if (str) {
+		nm_log_info (LOGD_DHCP4, "  NIS domain '%s'", str);
+		g_object_set_data_full (G_OBJECT (ip4_config), "NISDOMAIN", g_strdup (str), g_free);
+	}
+
+	str = g_hash_table_lookup (priv->options, "new_nis_servers");
+	if (str) {
+		nm_log_info (LOGD_DHCP4, "  NIS servers '%s'", str);
+		g_object_set_data_full (G_OBJECT (ip4_config), "NISSERVERS", g_strdup (str), g_free);
+	}
+
 	return ip4_config;
 
 error:
diff --git a/src/named-manager/nm-named-manager.c b/src/named-manager/nm-named-manager.c
index fc3b6e2..68a3892 100644
--- a/src/named-manager/nm-named-manager.c
+++ b/src/named-manager/nm-named-manager.c
@@ -98,6 +98,8 @@ typedef struct {
 	GPtrArray *nameservers;
 	const char *domain;
 	GPtrArray *searches;
+	const char *nis_domain;
+	const char *nis_servers;
 } NMResolvConfData;
 
 static void
@@ -148,6 +150,18 @@ merge_one_ip4_config (NMResolvConfData *rc, NMIP4Config *src)
 	num = nm_ip4_config_get_num_searches (src);
 	for (i = 0; i < num; i++)
 		add_string_item (rc->searches, nm_ip4_config_get_search (src, i));
+
+	if (!rc->nis_domain && !rc->nis_servers) {
+		const char *tmp;
+
+		tmp = g_object_get_data (G_OBJECT (src), "NISDOMAIN");
+		if (tmp)
+			rc->nis_domain = g_strdup (tmp);
+
+		tmp = g_object_get_data (G_OBJECT (src), "NISSERVERS");
+		if (tmp)
+			rc->nis_servers = g_strdup (tmp);
+	}
 }
 
 static void
@@ -240,6 +254,8 @@ dispatch_netconfig (const char *domain,
                     char **searches,
                     char **nameservers,
                     const char *iface,
+                    const char *nis_domain,
+                    const char *nis_servers,
                     GError **error)
 {
 	char *str;
@@ -283,6 +299,12 @@ dispatch_netconfig (const char *domain,
 		g_free (str);
 	}
 
+	if (nis_domain)
+		write_to_netconfig (fd, "NISDOMAIN", nis_domain);
+
+	if (nis_servers)
+		write_to_netconfig (fd, "NISSERVERS", nis_servers);
+
 	close (fd);
 
 	/* Wait until the process exits */
@@ -515,6 +537,8 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 	rc.nameservers = g_ptr_array_new ();
 	rc.domain = NULL;
 	rc.searches = g_ptr_array_new ();
+	rc.nis_domain = NULL;
+	rc.nis_servers = NULL;
 
 	if (priv->ip4_vpn_config)
 		merge_one_ip4_config (&rc, priv->ip4_vpn_config);
@@ -575,7 +599,10 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 
 #ifdef TARGET_SUSE
 	if (success == FALSE)
-		success = dispatch_netconfig (domain, searches, nameservers, iface, error);
+		success = dispatch_netconfig (domain, searches, nameservers, iface,
+				rc.nis_domain,
+				rc.nis_servers,
+				error);
 #endif
 
 	if (success == FALSE)
@@ -589,6 +616,11 @@ rewrite_resolv_conf (NMNamedManager *mgr, const char *iface, GError **error)
 	if (nameservers)
 		g_strfreev (nameservers);
 
+	if (rc.nis_domain)
+		g_free (rc.nis_domain);
+	if (rc.nis_servers)
+		g_free (rc.nis_servers);
+
 	return success;
 }
 


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